clearGridSelection
Removes all row selections in a grid control. This function deselects all currently selected rows in the specified grid.
Syntax
app.clearGridSelection(controlId)
Parameters
Parameter | Type | Description |
---|---|---|
controlId | String | The ID of the grid control from which all selections should be removed |
Return Value
This method doesn't return a value.
Description
The clearGridSelection
method allows you to programmatically deselect all rows in a grid control. This is useful when you want to reset the grid's selection state, for example before applying a new selection or when clearing filters.
The function works with DataTables-based grids and handles all the necessary internal calls to clear the selection state. After calling this function, the grid's selectedRows
property will be empty.
Examples
Basic Usage
// Clear all selected rows in a grid named "customerList"
app.clearGridSelection("customerList");
Clearing Selection Before Applying Filters
// Reset grid selection before applying a new filter
app.clearGridSelection("productGrid");
app.setFieldValue("categoryFilter", "Electronics");
app.refresh("productGrid");
Using in Event Handlers
app.addEventListener("onClick", "resetSelectionButton", function(eventArgs) {
// Clear the selection when the reset button is clicked
app.clearGridSelection("orderGrid");
app.showInfoMessage("Selection cleared", "All rows have been deselected");
});
Clearing Selection Before Selecting Specific Rows
// Clear current selection then select rows with a specific status
app.clearGridSelection("invoiceList");
app.selectGridRows("invoiceList", "status", "Unpaid");
Related Functions
- selectGridRows - Select specific rows in a grid based on a column value
- unselectGridRows - Deselect specific rows in a grid based on a column value
- toggleGridSelection - Invert the current row selection in a grid
- getFieldValue - Can be used with the '.selectedRows' suffix to get currently selected rows