10305 : How can I iterate through all loaded RootDataEntities? ( Only the loaded ones) (VCL version)

Question

Hi!
This should be easy for you, but I am lost:
Using a Gant with Grid and VirtualLoad, allowing Multiselect.
How can I iterate through all selected RootDataEntities?
( Only the loaded ones, i dont care about the unload ones ) Iterating all the BABCells gives an exception, when it comes to the unloaded ones. I cant find a way from a RootDataEntity.Item to the correspondent BABCell to check if its loaded or not.

Answer

You can go straight on the loaded grid rows; only loaded, check if they represent a root tree node then check select state:

procedure TForm1.ButtonIterareLoadedAllClick(Sender: TObject); begin
  for i:=0 to phGant1.MainGrid.AxisContentListY.LoadedCount-1 do
  begin
    if phGant1.Grid.AxisContentItemToGridTreeNode(phGant1.Grid.MainGrid.AxisContentListY.Loaded[i]).Level=0 then
    begin
    end;
  end;
end;

To check selection state on a cell in this loop you would go:
phGant_VL.Grid.Cell[x,phGant_VL.Grid.MainGrid.AxisContentListY.Loaded[i].ListIndex].Selected, where x is the column.

To be more precise:

for i:=0 to phGant2.Grid.MainGrid.AxisContentListY.LoadedCount-1 do
begin
  if phGant2.Grid.AxisContentItemToGridTreeNode(phGant2.Grid.MainGrid.AxisContentListY.Loaded[i]).Level=0 then
  begin
    If phGant2.Grid.Cell[0,phGant2.Grid.MainGrid.AxisContentListY.Loaded[i].ListIndex].Selected then
       // Do Stuff here
       // e.g. phGant2.Grid.AxisContentItemToGridTreeNode(phGant2.Grid.MainGrid.AxisContentListY.Loaded[i]).Userreference….
  end;
end;

Leave a Reply