Selecting rows and groups in the Server-Side Row Model is supported.
Just set the property rowSelection to either 'single' or 'multiple' as with any other row model.
Server-Side Row Selection requires Row ID's to be supplied to grid.
Row selection can be enabled in the grid by setting the rowSelection property to single or multiple. The below example demonstrates this property configured as multiple, note the following:
Checkboxes can be enabled on any column by setting checkboxSelection: true in the column defs. To enable a checkbox on a group column,
see the snippet on the Row Selection page.
The following example demonstrates checkbox selection with the SSRM. Note the following;
gridOptions.isRowSelectable(rowNode) callback.The header select-all checkbox can be enabled by setting headerCheckboxSelection: true on any column. This checkbox will toggle the selection state of every node loaded into the grid.
The following example demonstrates select-all with the SSRM. Note the following;
headerCheckboxSelectionFilteredOnly=true or headerCheckboxSelectionCurrentPageOnly=true is not supported when using the server-side row model.When using header checkbox selection with the server-side row model, you should not use the api functions getSelectedNodes() or getSelectedRows(). See the Selection API section below for suggested alternatives.
The grid can be configured to select children with their parents. This can be enabled by setting the grid property groupSelectsChildren: true.
The following example demonstrates groupSelectsChildren with the SSRM. Note the following;
United States group selects all of its children.United States → 2004 also deselects all of its children, and puts the United States row in an indeterminate state.When using group selection with the server-side row model, you should not use the api functions getSelectedNodes() or getSelectedRows(). See the Selection API section below for suggested alternatives.
When adding a new row via transaction, the new row will be treated as if it conforms to the parents selection. Therefore, if the parent row was selected the new row will be treated as selected upon creation. For indeterminate groups, this will follow the last non-indeterminate state. Note the following:
Add new Aggressive button, the new row is unselectedAggressive group, new rows created by the Add new Aggressive button will be selected.Aggressive group, new rows follow the groups previous selection state.The following API functions exist for the Server-Side Row Model when using Row Selection. These can be used to get the currently selected rows and nodes if all of the selected rows have been loaded by the grid. These cannot be used while using groupSelectsChildren or when any select all functionality is required.
When using selection where all selected rows may not have been loaded, it is instead advised to use api.getServerSideSelectionState and api.setServerSideSelectionState, as these functions can be used to identify selected rows without having ever loaded the rows.
The below snippet demonstrates how to set all nodes as selected, except for the row which has the ID United States, and the row with the ID United States2004.
this.gridApi.setServerSideSelectionState({
selectAll: true,
toggledNodes: ['United States', 'United States2004'],
});In the example below, note the following;
firstDataRendered callback, which sets the initial selection state.Save Selection button has been configured to store the result of api.getServerSideSelectionState(), it also logs the saved state to the console when clicked.Load Selection button can subsequently re-apply the previously saved selection rules using api.setServerSideSelectionState(state).The below snippet demonstrates how to set all nodes as selected, except for the row which has the ID United States, and its child row with the ID United States2004.
params.api.setServerSideSelectionState({
// this root level config can be used to determine a global select-all
selectAllChildren: true,
// all of the top level group nodes which do not conform with the select all value will have an entry here
// including indeterminate nodes
toggledNodes: [{
// as this is a group node with toggledNodes, this node will be marked as indeterminate
nodeId: 'United States',
// selectAllChildren can be used to determine whether this groups children are all selected
selectAllChildren: false,
toggledNodes: [{
// this group node has no toggledNodes, and so it will respect its own `selectAllChildren` property along
// with its descendants.
nodeId: 'United States2004',
selectAllChildren: true,
}],
}],
});In the example below, note the following;
firstDataRendered callback, which sets the initial selection state.Save Selection button has been configured to store the result of api.getServerSideSelectionState(), it also logs the saved state to the console when clicked.Load Selection button can subsequently re-apply the previously saved selection rules using api.setServerSideSelectionState(state).Row selection is also supported when using tree data. See this documented on the SSRM Tree Data page.
Continue to the next section to learn how to Change Columns.