Hi,
when using the ExpandNode and ContractNode Function I have an issue.
adding this to the "onDblClickCell":
if (sgTest.IsNode(ARow)) then
Begin
if (sgTest.NodeState[ARow]) then
Begin
sgTest.ExpandNode(ARow)
End else
Begin
sgTest.ContractNode(ARow);
End;
End;
leads to the problem, that the last Node wasn't handled. Instead the prior node was.
I hope you can validate this problem.
If I remove "ARow := RemapRow(ARow);" (line 16360) from
AdvGrid.procedure TAdvStringGrid.ExpandNodeInt(ARow: Integer);
and "ARow := RemapRow(ARow);" (line 16463) from
AdvGrid.procedure TAdvStringGrid.ContractNode(ARow: Integer);
everything seems to work fine for me, but I am sure there is a reason for this line.
So this is just an information for help.
Greetings from Irhove, germany
Peter Nomden
As a help, you can use this:
http://support.gymtv.eu/support/GridTest_NodeExpand.zip
Greetings from Irhove, germany
Peter Nomden
The ExpandNode / ContractNode functions work with the real row index and not the display row index.
Hence, the correct code is:
procedure TForm1.sgTestDblClickCell(Sender: TObject; ARow, ACol: Integer);
var
rr: integer;
begin
if (sgTest.IsNode(ARow)) then
Begin
rr := sgTest.RealRowIndex(Arow);
if (sgTest.NodeState[ARow]) then
Begin
sgTest.ExpandNode(rr)
End else
Begin
sgTest.ContractNode(rr);
End;
End;
end;
1 Like
Yes, this helped.
I don't get the right combination for ARow and rr.
I tried
if (sgTest.IsNode(ARow)) then
Begin
if (sgTest.NodeState[ARow]) then
Begin
sgTest.ExpandNode(ARow)
End else
Begin
sgTest.ContractNode(ARow);
End;
End;
and
rr := sgTest.RealRowIndex(ARow);
if (sgTest.IsNode(rr)) then
Begin
if (sgTest.NodeState[rr]) then
Begin
sgTest.ExpandNode(rr)
End else
Begin
sgTest.ContractNode(rr);
End;
End;
And both doesn't work. So it was a little confusing for me.
Thanks a lot.
Greetings from Irhove, germany
Peter Nomden
The real node index needs to be used for ExpandNode() / ContractNode() , not for the IsNode(), NodeState()