SMART datagrid v.1 > Classes > TreeDataSet

Back  Forward

DataLudi.TreeDataSet.insertRows  method

It inserts one or more child rows by values transferred by rows after the indexth child row of the existing Data Row specified by parameter parent

parent can specify TreeDataRow object or rowId. If parent is null, it will be added as the top row. rows can be an array of arrays according to field order or an array of JSON objects of which field names are properties. Just before adding rows, onRowsAdding event will be fired, and after adding them, onRowsAdded event will be fired. 

function insertRows (parent: TreeDataRow, index: Integer, rows: [Array], rowEvents: Boolean, noState: Boolean): [TreeDataRow];
Returns
[TreeDataRow]
Parameters
parent - TreeDataRow.
index - Integer. required.
rows - [Array]. required.
rowEvents - Boolean. Defaults to false.
noState - Boolean. Defaults to false.
Code -1
    $('#btnAdd').click(function () {
        var row = grid.focusedRow();
        var rows = [{
            name: $('#name1').val(),
            value: $('#value1').val()
        }, {
            name: $('#name2').val(),
            value: $('#value2').val()
        ]];
        dataset.insertRows(row.parent(), row.index(), rows);
    });
See Also
insertRows
insertRow
deleteRow
deleteRows
onRowsAdding
onRowsAdded
TreeDataRow
Tree Overview
Examples
Tree Data Set
Hello Tree