Contracting Nodes with Many Rows

I have a grid that may contain anywhere from a few dozen up to 1 million rows. To improve performance I am of course using GetDisplText to speed up the display of cells and everything is fine. The difficulty is that I want to add nodes that can span many rows. Adding the node with AddNode is a quick operation but contracting a node with many rows is extremely slow. Is there anything I can do to expand/contract large groups of rows? I suspect that the underlying issue is the speed of hiding rows and that maybe I need to take some approach other than the built-in node feature to achieve a node-like effect that can handle large spans. Do you have any thoughts on how to solve this? 

I have some insight into this. The speed of expanding and contracting nodes with large numbers of rows is reasonably fast if I expand or contract them in code using ContractAll and ExpandAll, provided that I wrap them in BeginUpdate and EndUpdate. The slowness comes in when expanding/contract by clicking the node indicator (the +) in the grid. Does this mean that you could modify the code behind the node indicator so that it also is wrapped in BeginUpdate and EndUpdate? Alternatively, is there any easy way for me to override the event that gets triggered when the node indicator is clicked?

  1. Did you try to use OnContractNode & OnExpandNode?
    2) For expanding/collapsing a single row in the grid with clicking the column header, I cannot see an issue here. Do you see this in any of our dems?

To reprodoce:

Drop an AdvStringGrid on a form and drop two tbuttons on the form. Hook up the following event handlers:
procedure TForm10.Button1Click(Sender: TObject);
begin
AdvStringGrid1.BeginUpdate;
AdvStringGrid1.ContractAll;
AdvStringGrid1.EndUpdate;
end;

procedure TForm10.Button2Click(Sender: TObject);
begin
AdvStringGrid1.BeginUpdate;
AdvStringGrid1.ExpandAll;
AdvStringGrid1.EndUpdate;
end;

procedure TForm10.FormCreate(Sender: TObject);
begin
AdvStringGrid1.RowCount:= 500000;
AdvStringGrid1.BeginUpdate;
AdvStringGrid1.AddNode(5,10000);
AdvStringGrid1.EndUpdate;
end;

Run the program and try contracting the span of 10000 rows by clicking the "+" in Row 5, Col 0. Result: it takes many seconds (about 1 minute on my machine)  for the node to contract. It will also take a very long time for the node to expand again when you click it again.

1. Now click Button1 and Button 2. The result: the rows expand and contract within a few seconds.

Why is the performance so different and how can I get it to be comparable? 

ContractAll is doing some optimizations and can do these because it is known in advance all rows within node span will be hidden. This optimization is not possible when doing a single node collapse in random order. We'll look if we can nevertheless improve performance for very large chunks of rows like in this case.

Bruno,

I appreciate your willingness to look into this. Can you give me a sense of how long it might take for you to determine whether you will be able to make any performance improvements? I need to decide whether to redesign part of my app or wait for potential improvements.
Thank you

With respect to timing, we are now very busy with the next TMS Component Pack & TMS Pack for FireMonkey release for later this month, early next month and after this release, we can again allocate time for this.