Back to Devexpress

ASPxClientGridView.SelectRows Method

aspnet-js-aspxclientgridview-2d3b31ab.md

latest4.7 KB
Original Source

ASPxClientGridView.SelectRows Method

Selects or deselects rows.

Declaration

ts
SelectRows(
    visibleIndices?: number[] | number,
    selected?: boolean
): void

Parameters

NameTypeDescription
visibleIndicesnumbernumber[]

The visible indices of rows.

| | selected | boolean |

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

|

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

aspx
<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>
js
function OnSelectAllRowsLinkClick() {
    grid.SelectRows();
}

Select the Row Specified by Its Visible Index

aspx
<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>
js
function onClick(s, e) {
    grid.SelectRows(3);
}

Select Multiple Rows Specified by Their Visible Indices

aspx
<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>
js
function onClick(s, e) {
    var indices = [1, 2, 3];
    grid.SelectRows(indices);
}

Select or Deselect the Row Specified by Its Visible Index

aspx
<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>
js
function onClick(s, e) {
    grid.SelectRows(3, checkBox.GetChecked());
}

Select or Deselect Multiple Rows Specified by Their Visible Indices

aspx
<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>
js
function onClick(s, e) {
    var indices = [1, 2, 3];
    grid.SelectRows(indices, checkBox.GetChecked());
}

Online Example

View Example: How to select all rows except disabled rows on the client side

See Also

ASPxClientGridView Class

ASPxClientGridView Members