Anda di halaman 1dari 6

ADVGRID

Property No 1. 2. 3. 4. 5. 6. 7. 8. 9. 10 . 11 . 12 . 13 . 14 . 15 . 16 . 17 . 18 . 19 . 20 . Property Name Bands.Active ColumnSize.Stretch ExcelStyleDecimalSeparator FixedColAlways FixedRowlAlways FixedFont.Style.Bold Navigation.AdvanceOnEnter Navigation.AutoComboDropSize Navigation.AllowInsertRow Options.GoColSizing Options.GoTabs SizeWhileTyping.Width SortSetting SortSettings.NormalCellsOnly SortSettings.Show SortSettings.Row WordWrap VAlignment ColumnHeaders.Count True True 0 Fasle vtaCenter 1 Value asgXxxx True True True True True True True True True True True True

Event ClickCell if (ARow = 0) and (ACol = ColNode) then begin asgGrid.Cells[ColNode,0] := IfThen(asgGrid.Cells[ColNode,0]='[-]','[+]','[-]'); if asgGrid.Cells[ColNode,0] = '[-]' then asgGrid.ContractAll

else asgGrid.ExpandAll; asgGrid.AutoSizeColumns(True); end;

ContractNode asgGrid.AutoSizeColumns(True); asgGrid.ColumnHeaders;

ExpandNode asgGrid.AutoSizeColumns(True);

GetAlignment if (ARow = 0) or (ACol in [ColLP, ColStat]) then HAlign := taCenter else if ACol in [ColUmur, ColBerat] then HAlign := taRightJustify; VAlign := vtaCenter;

AutoAddRow asgInput.AddCheckBox(ColStat, ARow, False, False);

CanEditCell CanEdit := ACol in [ColNama, ColUmur, ColTglLhr, ColLP, ColStat, ColBerat];

CellValidate if ACol = ColUmur then begin if StrToIntDef(Value, 0) < 5 then asgInput.Cells[ColKtgr, ARow] := 'Balita' else if (StrToIntDef(Value, 0) >= 5) and (StrToIntDef(Value,0) <= 11) then asgInput.Cells[ColKtgr, ARow] := 'Anak-anak'

else if (StrToIntDef(Value, 0) >= 12) and (StrToIntDef(Value,0) <= 25) then asgInput.Cells[ColKtgr, ARow] := 'Remaja' else if (StrToIntDef(Value, 0) >= 26) and (StrToIntDef(Value,0) <= 50) then asgInput.Cells[ColKtgr, ARow] := 'Dewasa' else if StrToIntDef(Value, 0) > 51 then asgInput.Cells[ColKtgr, ARow] := 'Orang Tua' end; asgInput.AutoNumberCol(ColNo); asgInput.AutoSizeColumns(True);

GetEditorType case ACol of ColNama : AEditor := edMixedCase; ColUmur : AEditor := edPositiveNumeric; ColTglLhr : AEditor := edDateEdit; ColLP : begin AEditor := edComboList; asgInput.Combobox.Items.Clear; asgInput.Combobox.Items.Append('Laki-laki'); asgInput.Combobox.Items.Append('Perempuan'); end; ColStat : AEditor := edCheckBox; ColBerat : AEditor := edFloat; end;

Perintah SetGrid asgRekap.ExpandAll; asgRekap.RemoveAllNodes;

asgRekap.ClearNormalCells; asgRekap.RowCount := 2; asgRekap.ColCount := 8; asgRekap.FixedCols := 0; asgRekap.FixedRows := 1; asgRekap.AutoSizeColumns(True);

Memasukan data ke grid yang bernode var i, j, R1, R2 : integer; begin SetGrid; for i := 0 to length(ArrKtgr)-1 do begin if i > 0 then asgGrid.AddRow; R1 := asgGrid.RowCount-1; asgGrid.MergeCells(ColNama, R1, 6, 1); asgGrid.Cells[ColNama, R1] := ArrKtgr[i]; asgGrid.FontStyles[ColNama, R1] := [fsBold]; asgGrid.FontColors[ColNama, R1] := clTeal; for j := 0 to length(ArrData)-1 do begin if ArrData[j].Kategori = ArrKtgr[i] then begin asgGrid.AddRow; R2 := asgGrid.RowCount-1; asgGrid.Cells[ColNama, R2] := ArrData[j].Nama; asgGrid.Ints[ColUmur, R2] := ArrData[j].Umur; asgGrid.Dates[ColTglLhr, R2] := ArrData[j].Tgl_Lahir; asgGrid.Cells[ColLP, R2] := IfThen(ArrData[j].JnsKelamin = 'L', 'Laki-laki', 'Perempuan'); asgGrid.Cells[ColStat, R2] := IfThen(ArrData[j].IsMenikah, 'True', 'False');

asgGrid.Floats[ColBerat, R2] := ArrData[j].BeratBdn; end; end; R2 := asgGrid.RowCount-1; if R1 <> R2 then asgGrid.AddNode(R1, R2-R1+1); end; asgGrid.ContractAll; asgGrid.Cells[ColNode, 0] := '[-]'; asgGrid.AutoSizeColumns(True);

Menyimpan data grid ke record var i, idx : integer; stat : Boolean; begin for i := 1 to asgInput.RowCount-1 do begin if asgInput.Cells[ColNama, i] <> '' then begin setlength(frmRekap.ArrData, length(frmRekap.ArrData)+1); idx := length(frmRekap.ArrData)-1; frmRekap.ArrData[idx].Nama := asgInput.Cells[ColNama, i]; frmRekap.ArrData[idx].Umur := asgInput.Ints[ColUmur, i]; frmRekap.ArrData[idx].Kategori := asgInput.Cells[ColKtgr, i]; frmRekap.ArrData[idx].Tgl_Lahir := asgInput.Dates[ColTglLhr, i]; frmRekap.ArrData[idx].JnsKelamin := IfThen(asgInput.Cells[ColLP, i] = 'Laki-laki', 'L', 'P'); asgInput.GetCheckBoxState(ColStat, i, stat); frmRekap.ArrData[idx].IsMenikah := stat; frmRekap.ArrData[idx].BeratBdn := asgInput.Floats[ColBerat, i]; end; end;

// ModalResult := mrOk; SetGrid; ShowMessage('Hore.. Grid sudah bersih..'+#13+'Isi lagi yukz..'); asgInput.Col := ColNama; asgInput.Row := 1;

Anda mungkin juga menyukai