Search
ArrayModel.addRow Method
See Also
 






Adds a row to the backing array.

Namespace: MindFusion.DataViews
File: ArrayModel.js

 Syntax

JavaScript  Copy Code

function addRow ([rowData, [index]])

 Parameters

rowData
Optional.

Object. The values to add.

index
Optional.

Number. The index at which to insert the data. If not specified, the data will be appended to the end of the backing array.

 Example

The following sample adds a new row at the end of the Grid rows and moves the cursor there so that the user can start typing data:

JavaScript  Copy Code

function onAddClick(sender)
{
    grid.allowEdit = true;
    grid.allowCellSelect = true;

    var data = grid.model.getRowData(grid.model.rowCount);
    var maxIndex = grid.model.getMaxKey();
    data.index = ++maxIndex;

    grid.addRow(data).then((newRow) =>
    {
        editRow = newRow;
        grid.refreshRows(newRow);
        setEditMode();
    });
}

 See Also