aspnet-js-aspxclientgridview-2d3b31ab.md
Selects or deselects rows.
SelectRows(
visibleIndices?: number[] | number,
selected?: boolean
): void
| Name | Type | Description |
|---|---|---|
| visibleIndices | number | number[] |
The visible indices of rows.
| | selected | boolean |
true or undefined to select the row(s); false to deselect the row(s).
|
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.
<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();
}
<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);
}
<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);
}
<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());
}
<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());
}
View Example: How to select all rows except disabled rows on the client side
See Also