Skip to main content

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

ParameterTypeDescription
controlIdStringThe 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");