Expand all treeGrid Nodes down to a specified LEVEL.

Hi -

We have the need to expand a treeGrid object down to a specified level. We saw the question & answer from June 2008 where the user wanted to expand to a specific NODE; we need to expand all nodes down to a specific LEVEL.

For example: (where L = level; N = Node), and the following tree:

L1-N1
L1-N2
  L2-N1
  L2-N2
    L3-N1
    L3-N2
    L3-N3
  L2-N3
    L3-N4
  L2-N4

If L=2, we’d want to see:

L1-N1
L1-N2
  L2-N1
+ L2-N2
+ L2-N3
  L2-N4

The tree starts out collapsed (that is, upon load we do not call expandAll). Also, the level to which we would like to expand is not always “2”.

We are using javascript to create the tree grid object, and the LoadXML function to load the data (will be going to a dynamic model very shortly - as we have large numbers of nodes to display)

Does such a function already exist? I did not find one in the treeGrid API. Suggestions?

Thanks.

dhtmlxTreeGrid doesn’t have such method. But you can use openItem(rowId) method to open specific row.
You can get all sub item of the node with getAllSubItems(rowId) method
Please find list of TreeGrid related API here docs.dhtmlx.com/doku.php?id=dhtm … _toc_alpha

I tried this suggestion but using openItem programatically only opens the last row, e.g.

 $("#expand_all").bind("click", function(e) {
                            e.preventDefault();
                            var grid = document.getElementById('report_gridbox').grid;
                            var grid_rows_list = report_grid_obj.getAllSubItems();
                            var grid_rows = grid_rows_list.split(',');
                            for (var i = 0; i < 5; i++) {
                              grid.openItem(grid_rows[i]);
                            }

                          });

This should look like:

Row 1
|-- Item 1
Row 2
|-- Item 2
Row 3
|-- Item 3
Row 4
|-- Item 4
Row 5
|-- Item 5

However it looks like this:

Row 1
Row 2
Row 3
Row 4
Row 5
|-- Item 5

I am using dhtmlxtreegrid with dynamic XML and loading kids when row is opened. I can see the requests in Firebug console each item openItem is called but the grid does not open any rows except for the last one.

Any idea how to implement a true ExpandAll function for treegrid when using XML/kids ?

Thanks for your help
Tim

Your issue is confirmed.
The fix can be created, but unfortunately it won’t be included in the future versions of dhtmlxgrid.
If you need this custom fix, please, open ticket at support.dhtmlx.com so we can provide it to you.