//0.Search Manual: TcxCustomDataController.ForEachRow
//1. set properties for multi-selection
----------------------------------------------------------
MainGridView.OptionsSelection.MultiSelect := true;
MainGridView.DataController.KeyFieldNames := 'SONo';
FSelectSONoList := TStringList.Create;
----------------------------------------------------------
//2.prepare a callback function to save what you would selected
----------------------------------------------------------
procedure TfrmSOSchedule.SaveSelectedSO(ARowIndex: Integer;
ARowInfo: TcxRowInfo);
begin
with MainGridView.DataController do
begin
//test whether a row is a data record
if ARowInfo.Level = Groups.GroupingItemCount then
FSelectSONoList.Add(String(GetRecordId(ARowInfo.RecordIndex)));
end;
end;
----------------------------------------------------------
//3.use the selected entries
----------------------------------------------------------
procedure TfrmSOSchedule.btnUpdateSelectedSOClick(Sender: TObject);
var
i: Integer;
begin
FSelectSONoList.BeginUpdate;
try
FSelectSONoList.Clear;
MainGridView.DataController.ForEachRow(true, SaveSelectedSO);
finally
FSelectSONoList.EndUpdate;
end;
with MainGridView.DataController.DataSource.DataSet do
begin
DisableControls;
try
for i := 0 to FSelectSONoList.Count - 1 do
begin
if Locate('SONo', FSelectSONoList[i], []) then
FindField('status').AsInteger := 1;
end;
finally
PostSaleOrders;
EnableControls;
end;
end;
end;