Skip to main content

ASPxClientGridView.SelectRowsByKey(keys) Method

Selects or deselects the rows specified by their key values.

Declaration

SelectRowsByKey(
    keys: any[] | any,
    selected?: boolean
): void

Parameters

Name Type Description
keys any

The key values of the rows.

selected boolean

true or undefined to select the specified row(s); false to deselect the row(s).

Remarks

The SelectRowsByKey(key) method sends a callback to the server to apply the row selection.

When the row selection changes, the control raises the client-side ASPxClientGridView.SelectionChanged or the server-side ASPxGridBase.SelectionChanged event (based on the ProcessSelectionChangedOnServer property value).

For more information on row selection in grid, refer to the following topic: Selection.

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" KeyFieldName="ProductID" runat="server">
</dx:ASPxGridView>
// Select a single row
grid.SelectRowsByKey(2);

// Or
grid.SelectRowsByKey(2, true);

// Deselect a single row
grid.SelectRowsByKey(2, false);

// Select multiple rows
grid.SelectRowsByKey([2,10]);

// Or
grid.SelectRowsByKey([2,10], true);

// Deselect multiple rows
grid.SelectRowsByKey([2,10], false);

Select the Row(s) Specified by the Composite Key Value(s)

<dx:ASPxGridView ID="grid" ClientInstanceName="grid" KeyFieldName="ProductID;ProductName" runat="server">
</dx:ASPxGridView>
// Select a single row
grid.SelectRowsByKey("2|Chang");

// Or
grid.SelectRowsByKey("2|Chang", true);

// Deselect a single row
grid.SelectRowsByKey("2|Chang", false);

// Select multiple rows
grid.SelectRowsByKey(["2|Chang","10|Ikura"]);

// Or
grid.SelectRowsByKey(["2|Chang","10|Ikura"], true);

// Deselect multiple rows
grid.SelectRowsByKey(["2|Chang","10|Ikura"], false);
See Also