ASPxClientGridView.SelectRows Method
Selects or deselects rows.
Declaration
SelectRows(
visibleIndices?: number[] | number,
selected?: boolean
): void
Parameters
Name | Type | Description |
---|---|---|
visibleIndices | number | number[] | The visible indices of rows. |
selected | boolean |
|
Remarks
If the visibleIndices
parameter is not specified, the SelectRows
method selects or deselects all rows in the grid.
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 the grid, refer to the following topic: Selection.
Examples
Select All Grid Rows
<dx:ASPxHyperLink ID="lnkSelectAllRows" ClientInstanceName="lnkSelectAllRows" runat="server"
Text="Select all rows" Cursor="pointer" ClientSideEvents-Click="OnSelectAllRowsLinkClick" />
<dx:ASPxGridView ID="grid" ClientInstanceName="grid" runat="server">
<ClientSideEvents Init="OnGridViewInit" SelectionChanged="OnGridViewSelectionChanged"
EndCallback="OnGridViewEndCallback" />
<%--...--%>
</dx:ASPxGridView>
function OnSelectAllRowsLinkClick() {
grid.SelectRows();
}
Select the Row Specified by Its Visible Index
<dx:ASPxGridView ID="ASPxGridView1" ClientInstanceName="grid" runat="server">
<%--...--%>
</dx:ASPxGridView>
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Select Row">
<ClientSideEvents Click="onClick" />
</dx:ASPxButton>
function onClick(s, e) {
grid.SelectRows(3);
}
Select Multiple Rows Specified by Their Visible Indices
<dx:ASPxGridView ID="ASPxGridView1" ClientInstanceName="grid" runat="server">
<%--...--%>
</dx:ASPxGridView>
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Select Rows">
<ClientSideEvents Click="onClick" />
</dx:ASPxButton>
function onClick(s, e) {
var indices = [1, 2, 3];
grid.SelectRows(indices);
}
Select or Deselect the Row Specified by Its Visible Index
<dx:ASPxGridView ID="ASPxGridView1" ClientInstanceName="grid" runat="server">
<%--...--%>
</dx:ASPxGridView>
<dx:ASPxCheckBox ID="ASPxCheckBox1" ClientInstanceName="checkBox" runat="server" Text="Select Rows"/>
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Process">
<ClientSideEvents Click="onClick" />
</dx:ASPxButton>
function onClick(s, e) {
grid.SelectRows(3, checkBox.GetChecked());
}
Select or Deselect Multiple Rows Specified by Their Visible Indices
<dx:ASPxGridView ID="ASPxGridView1" ClientInstanceName="grid" runat="server">
<%--...--%>
</dx:ASPxGridView>
<dx:ASPxCheckBox ID="ASPxCheckBox1" ClientInstanceName="checkBox" runat="server" Text="Select Rows" />
<dx:ASPxButton ID="ASPxButton1" runat="server" AutoPostBack="False" Text="Process">
<ClientSideEvents Click="onClick" />
</dx:ASPxButton>
function onClick(s, e) {
var indices = [1, 2, 3];
grid.SelectRows(indices, checkBox.GetChecked());
}
Online Example
See Also