SMART datagrid v.1 > Examples

Back  Forward

Check Bar  Example

Each Row of the grid can have a Checked state. If EditOptions.checkable is true, the user can click the check cells of the check bar displayed on the left side of the grid during the run time to change the checked state of the grid rows. In addition, there are many api properties and methods related to checked

Grid - 1
rows

If specify as true, the user can only select one row, and the shape of the check box will be displayed as a radio button type. 

If specify CheckBar.draggable as true, the user can select the location by dragging rather than clicking each check cell one by one. If press ctrl key and drag, the checked state will be toggled. 

Code -1
    grid.checkBar().setExclusive(ev.target.checked);

The check state of the grid row can also be used in the dynamic style.  

Code -2
    grid.body().setCellDynamicStyles([{
        criteria: 'checked',
        styles: { background: '#3000ff00' }
    }]);

The list of the checked rows can be imported through GridBase.getCheckedRows method.  

Code -3
    var rows = grdMain.getCheckedRows();
    grdMain.deleteRows(rows, true);

There are also some APIs which can tell whether the grid row has been checked, or check and uncheck the specified rows. You can test it in the grid below. The checked state of Grid Row is managed in the grid level rather than Data Set value. In other words, even if both of the grids have been connected to the same data set, the checked state specified in the bottom grid is separate from the one of the top grid. 


Grid - 2
rows

If set CheckBar.checkAllExpression or checkAllCallback, when the user clicks the "Select All" button, only the rows which have returned true in the specified function or callback will be checked. 


View Source JSP 

See Also
CheckBar
CheckBar.exclusive
EditOptions.checkable
GridBase.checkBar
GridBase.checkRow
GridBase.checkRows
GridBase.checkAll
GridBase.getSelectedRows
GridBase.onRowChecked
GridBase.onRowsChecked
Examples
Checkable Expression & Callback