Documents

NextGrid & NextDBGrid

NextGrid

NextDBGrid

NextInspector

NextSheet

NextCollection

Misc

Labs

NextGrid .NET

TreeColumn Tutorial

Related Articles:

Info
  • Skill:
  • Version: 1.0.1
  • Author: Bojan Nikolic
  • Created:
  • Updated: 2008-04-22
In this tutorial we will demonstrate how to create tree inside Next Grid.

Please note that Tree Column implementation is still in stage and we work to improve it constantly.

Adding TreeColumn



TreeColumn (TNxTreeColumn) is normal NextGrid column and can be added at any place inside Grid, any times needed.

To add one TNxTreeColumn, click on TreeColumn icon:



Customizing TreeColumn



TreeColumn appearance can be customized with following properties:

ExpandLock - Disable clicking on and buttons.

ShowLines - Show/Hide Tree Lines.

ShowButtons - Show/Hide and buttons.

Adding Rows



Tree structure can be build with AddChildRow and InsertChildRows methods.

AddChildRow method have following parameters:

Table 1: AddChildRow Parameters
Name Type Meaning
Index Integer Index of Parent Row.
Position (optional) Integer Position of Child Row (crFirst - new row will be first child row, crLast - new row will be last child row


with NextGrid1 do
begin
  AddRow;
  Cells[0, LastAddedRow] := '[root]';
  AddChildRow(0);
  Cells[0, LastAddedRow] := 'two';
  AddChildRow(0);
  Cells[0, LastAddedRow] := 'one';
  AddChildRow(0);
  Cells[0, LastAddedRow] := 'three';
  AddChildRow(LastAddedRow);
  Cells[0, LastAddedRow] := 'one more child row';
end;


Result:



In this sample we have use property LastAddedRow to determine Index of last added row inside Grid.

Deleting Rows



Child row may be deleted with using DeleteRow method and with sending Row's absolute index as parameter:

DeleteRow(AbsoluteIndexOfRow);

To delete child row, without knowing absolute index, use DeleteChildRow method:

DeleteChildRow(ParentIndex, Index);

Table 2: DeleteChildRow Parameters
Name Type Meaning
ParentIndex Integer Determine absolute index of parent row
Index Integer determine relative index of child row inside Parent row.


Working with Nodes



NextGrid also have several methods for easy working with Nodes.

GetNextSibling returns the next row (node) in the tree at the same level as the calling row.

GetPrevSibling returns the previous row (node) in the tree at the same level as the calling row.

Was This Article Useful?

Comments

2009-10-18 14:51:28

How to find out, which level a selected node is?

2009-10-18 15:01:29

Find it by myself: It's a Row.Property.

But I have a redraw problem with NextGrid - HeaderStyle - hsOffice2007

2009-10-18 16:22:31

Hi,

Can you please send me a screenshot , or small demo project of redraw problem on boki@bergsoft.net

Best regards
Only constructive comments, code contributions... will be publishes. Questions, non-official discussion will not be published.