Jump to content


Photo

Expand/Collapse Tree Column button not working


  • Please log in to reply
10 replies to this topic

#1 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 08 September 2007 - 02:09 PM

Hello, Boki:

Just added a new column to my table/grid editor, the NxTreeColumn, but after adding a number of nodes from a VirtualStringTree, the expand button is not working. Otherwise everything is fine.

I looked at your demo4 code and could not find any setting to make this work.

Any suggestions?

Here's my routine:

CODE
//a recursive loading of the NxTreeColumn
//ParentNode is defined as Public var, folder node to which table is assigned
//TreeCol
procedure TfrmCVTable.MakeFirstColTree(Tree: TVirtualStringTree;
TreeCol:boolean; ParentNode :PVirtualNode);
//local procedure
//ParentIndex : row position of parent adding to
//Level: 0-n deep, 0 is the first, most left aligned level

procedure AddAllChildrenToTreeCol(Node, ParentNode : PVirtualNode;
ParentIndex, Level: integer);
var
//initialize all children of the node
Data : PNodeData;
ChildNode : PVirtualNode;
RowIndex : integer;

begin

if Node = ParentNode then
begin
Node := Node.FirstChild;
end;

while Node <> nil do
begin
Data := Tree.GetNodeData(Node);

with GridView1 do
begin
if Level = 0 then
begin
AddRow
end
else
if Level > 0 then
//parentIndex = RowIndex of the calling routine
AddChildRow(ParentIndex);

RowIndex := LastAddedRow;

Cells[1,LastAddedRow] := Data.Description;
end; //with gridview1

//check node for children and add those
Tree.ReinitChildren(node,false);
ChildNode := Node.FirstChild;

if ChildNode <> nil then
begin
AddAllChildrenToTreeCol(ChildNode, ParentNode, RowIndex,Level + 1);
end;

GridView1.Expanded[ParentIndex] := false;

Node := Node.NextSibling;
end; //while Node <> nil

end;
//end of local procedure

var
Node : PVirtualNode;
i : integer;
Data : PNodeData;

begin
if TreeCol then
begin
//start with the node to which the table is being added
Node := ParentNode;
Data := TV.CurrentCVTree.GetNodeData(Node);

GridView1.ClearRows;
NxTextColumn1.Visible := false;
GridView1.Columns.Add(TNxTreeColumn, Data.Description );

with TNxTreeColumn(GridView1.Columns[1]) do
begin
options := [coCanClick, coCanInput, coPublicUsing, coShowTextFitHint];
ShowLines := true;
//Node := Tree.FocusedNode;
//make sure the node.childcount is correct and tree nodes'data is available
Tree.ReinitChildren(node,false);

//next is recursive
//parent Index at start is 0

AddAllChildrenToTreeCol(Node, ParentNode, 0,0);

end;

end; //if TreeCol

end;


#2 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 08 September 2007 - 02:49 PM

Hello Chuck,

Unfortunatelly, I didn't success to find where is problem because I don't have TVirtualStringTree class). I have made common code needed for using with TreeColumn:

Please note that TreeColumn still have some limitations (such sorting and moving child rows) bu this will be done durring time.

Sample Project:
Attached File  treecol.zip   1.73KB   5 downloads

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#3 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 08 September 2007 - 09:08 PM

Hello, Boki:

The VirtualTreeView is not the issue. I just reiterate through the nodes getting their description data and assigning that to the Cell[] property. In a sense its just like any other data source.

The difference could be that after going through my example table, which represents a section of the displayed tree, the routine has added about 250 nodes to the TreeColumn.

I have used the TreeColumn in a different context in my program for a much smaller tree (about 50 nodes) and it works fine there.

Could this be the issue? i.e. too many nodes added?

Thanks,

Chuck

I will look over your Tree zip, too.

#4 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 08 September 2007 - 09:14 PM

Hello, Boki:

Just went over the Tree zip you uploaded and yes, that is how I'm adding the nodes.

The tree displays the structure perfectly, its just that I can't collapse/expand the branches using the little "+" button.

After the last problem with NxComboBoxColumn, I added the coEditing just to be sure and it made no difference.

Its in the button click someplace?

Chuck

#5 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 08 September 2007 - 09:23 PM

Hello Chuck,

Maybe coCanClick is missed, or, ReadOnly is set to true?

PS. I didn't understand, does clicking on -/+ work in my zip sample?

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#6 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 09 September 2007 - 12:06 AM

I specifically add coCanClick to options.

My NextGrid has ReadOnly set to False and I believe I do not change that. I added ReadOnly := False specifically for this column, no change. Although, when testing it, a TreeColumn in a readonly grid acts the same as I'm describing.

I played with your zipped project and even added 500 child nodes with desciption to a couple of nodes and everything seemed to work fine.

Tried to eliminate the call to my OnBeforeEdit (again!) and this helped considerably, but now there are more weird behaviors:

1. First the +/- buttons work on the first and last 1st level nodes that have children.
2. When clicking on 1st level but 2nd or subsequent rows with children, instead of closing the node, the cursor jumps about 50 nodes down the grid. The parent node is not closed up.
3. If as I create and fill the TreeColumn at run time by Expand := false, then as expected all parents are collapsed, but when clicked on, only one child row becomes exposed, not all. If I create the treecol and leave expanded, then all nodes are visible as expected, but then buttons don't quite work (see 1,2)

Unless you have some suggestions, I will try to recreate this behavior in your project by mimicking the size of my tree in your project. I hope to send this back for you to look at.

Chuck

#7 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 09 September 2007 - 12:16 AM

Hello Chuck,

If you can expand my sample this will be great and help a lot. I have now play with Demo 4 again and haven't find any problem like this sad.gif

Expanding demo will help for sure.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#8 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 09 September 2007 - 02:59 AM

Hello, Boki:

I used your simple project to recreate the structure of my treeview, i.e. 6 parent nodes each with 100 children, all have description. I could not duplicate the issue that I've been seeing.

Again, I'll try stripping out all events code that I have active in my own code and see if something in them is causing this. I'll let you know what I find.

Thanks again,

Chuck

#9 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 09 September 2007 - 03:03 AM

Hello Chuck,

Thank you. I am ready to hear new results.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.

#10 BelangerC

BelangerC

    Senior Member

  • Members
  • PipPip
  • 221 posts
  • Location:Richmond, CA USA
  • Interests:Alternative medicine, programming for

Posted 10 September 2007 - 05:22 PM

Hello, Boki:

I found the problem.

Turns out that setting the NextGrid's AutoScroll = true reproduces the effects that I was seeing.

What's ironic is that AutoScroll doesn't seem to add/remove any features; if the grid has more rows than it can hold, the scroll bar displays no matter the setting. But, with a tree col if True, you can't properly open or close the parent nodes, except the first and last one.

I've attached the simple project you made, and made the tree col's longer to match what I was doing so you can see this and fix it, if you want. At the minimum you might want to tell people not to set Autoscroll on.

Best regards,

Chuck

Attached Files



#11 Boki (Berg)

Boki (Berg)

    Boki (Berg)

  • Forum Admin
  • PipPipPipPipPip
  • 8,191 posts
  • Gender:Male

Posted 10 September 2007 - 09:59 PM

Hello Chuck,

Thank you for your sample. I will look at it and fix it.

Best regards
boki@bergsoft.net | LinkedIn Profile
--
BergSoft Home Page: www.bergsoft.net
Users Section: users.bergsoft.net
Articles and Tutorials: help.bergsoft.net (Developers Network)
--
BergSoft Facebook page
--
Send us applications made with our components and we will submit them on: www.bergsoft.net/apps.htm. Link to this page will be also set on home page too.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users