SMART datagrid v.1 > Classes > TreeDataSet

Back  Forward

DataLudi.TreeDataSet.appendDataRows  method

It creates data rows from the array of arrays which contain tree information and have been sorted in data set field order and adds them to the end of parent row specified by parent

In order to insert in the middle location, it will use insertDataRows. Please refer to setRows about the way of organizing the tree by using parameters. 

function appendDataRows (parent: TreeDataRow, rows: Array, treeField: String, useTreeField: Boolean, needSorting: Boolean);
Returns
Void
Parameters
parent - TreeDataRow. required.
The parent Data Row in which will add data rows of being created. If it is null, it will become children of Root row of data set.
rows - Array. required.
The array of arrays in which contain tree field and field values.
treeField - String. required.
The location of value which is used as tree information among each array of rows.
useTreeField - Boolean. required.
If it is true, it will add the value corresponding to treeField to data set.
needSorting - Boolean. required.
Before organizing the tree, it will sort by the value corresponding to treeField.
Code -1
    // It is the same as below call.
    ds.insertDataRows(parent, parent.count(), rows, treeField, useTreeField, needSorting);
Code -2
    var rows = [
        [0, "1","IBRD00010","France","4.25","USD","P037383","250","000","001.00","11/01/1952","05/01/1977"],
        [1, "1.1","IBRD00020","Netherlands","4.25","USD","P037452","191","044","211.75","04/01/1952","10/01/1972"],
        [1, "1.2","IBRD00021","Netherlands","4.25","USD","P037452","3","955","788.25","04/01/1953","04/01/1954"],
        [2, "1.2.1","IBRD00030","Denmark","4.25","USD","P037362","40","000","000.00","02/01/1953","08/01/1972"],
        [3, "1.2.2","IBRD00040","Luxembourg","4.25","USD","P037451","12","000","000.00","07/15/1949","07/15/1972"]
    ];
    var p = treeMain.focusedDataRow();
    if (p) {
        // Do not use treeField and no need to sort since it has already been sorted.
        dsMain.appendDataRows(p, rows, 1, false, false);
        
        treeMain.expand(treeMain.focusedRow());
        var row = row.getChild(p.count() - 1);
        row = treeMain.getRowOfDataRow(row);
        treeMain.expand(row, true);
        treeMain.setFocusedRow(row);
    }
See Also
insertDataRows
setRows
appendJsonRows
appendXmlRows
Examples
Append Tree Data
Load Tree Data
Tree Data Set