SMART datagrid v.1 > Classes > GridDataSet

Back  Forward

DataLudi.GridDataSet.appendRows  method

Append original data of one or more data rows which are transferred by rows array after the last row of data set, and return the number of rows which have been actually appended. The data of each row which is contained in rows can be array or JSON object, and JSON object will be arranged and stored as array according to field order. 

function appendRows (rows: Array, start: Number, count: Number, rowEvents: Boolean): Integer;
Returns
Integer - The rows which have been added actually.
Parameters
rows - Array. required.
start - Number. Defaults to 0.
count - Number. Defaults to -1.
rowEvents - Boolean. Defaults to false.
If it is true, confirmation and completion event will be fired in row unit. If it is DataSet.undoable, events in row unit will not be fired regardless of this property.
Note
Code -1
    // If rowEvents is false, the event will be fired when appending of all rows is committed.
    ds.onRowsInserted = function (ds, row, count) {
        console.log(row + '' + count + ' row has been appended in  th row location.';
    };
    // If rowEvents is true, the event will be fired whenever each row is appended.
    ds.onRowInserted = function (ds, row) {
        console.log(row + 'One row has been appended in  th row location.';
    };
    
    // Each row which is transferred by function can be array or JSON object.
    var rows = [
        ['value1', 'value2', 'value3', 111, 222],
        {
            'field1': 'value11', 
            'field2': 'value12',
            'field3': 'value13',
            'field4': 666,
            'field5': 777
        }
    ];
    // If the count is -1, it will append all rows of rows, and if it is greater than 0, it will append as much as Math.min(count, rows.length).
    ds.appendRows(rows, 0, -1, false);
See Also
insertRows
appendRow
insertRow
Examples
Grid Data Set Edit