Back to Devexpress

ASPxClientGridView.SelectRowsByKey(keys) Method

aspnet-js-aspxclientgridview-dot-selectrowsbykey-x28-keys-x29.md

latest2.4 KB
Original Source

ASPxClientGridView.SelectRowsByKey(keys) Method

Selects or deselects the rows specified by their key values.

Declaration

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

Parameters

NameTypeDescription
keysany

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.

aspx
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" KeyFieldName="ProductID" runat="server">
</dx:ASPxGridView>
js
// 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)

aspx
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" KeyFieldName="ProductID;ProductName" runat="server">
</dx:ASPxGridView>
js
// 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

ASPxClientGridView Class

ASPxClientGridView Members