Back to Devexpress

ASPxClientGridView.SetFocusedRowIndex(visibleIndex) Method

aspnet-js-aspxclientgridview-dot-setfocusedrowindex-x28-visibleindex-x29.md

latest2.5 KB
Original Source

ASPxClientGridView.SetFocusedRowIndex(visibleIndex) Method

Moves focus to the specified row.

Declaration

ts
SetFocusedRowIndex(
    visibleIndex: number
): void

Parameters

NameTypeDescription
visibleIndexnumber

The row index.

|

Remarks

Set the AllowFocusedRow property to true to enable row focus.

Call the SetFocusedRowIndex(visibleiIndex) method to focus the corresponding row within the current page. When the row focus changes, the server-side ASPxGridView.FocusedRowChanged or the client-side ASPxClientGridView.FocusedRowChanged event fires (based on the ProcessFocusedRowChangedOnServer property value). If you navigate to another page, the row loses focus.

Example

aspx
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False"
    ClientInstanceName="grid" KeyFieldName="CategoryID">
    <SettingsBehavior AllowFocusedRow="true" />
    <SettingsDetail ShowDetailRow="True" AllowOnlyOneMasterRowExpanded="true" />
    <ClientSideEvents DetailRowExpanding="OnDetailRowExpanding" />
    <Columns><%--...--%></Columns>
    <Templates>
        <DetailRow>
            <dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False"
                OnBeforePerformDataSelect="ASPxGridView2_BeforePerformDataSelect">
                <Columns><%--...--%></Columns>
            </dx:ASPxGridView>
        </DetailRow>
    </Templates>
</dx:ASPxGridView>
js
function OnDetailRowExpanding(s, e) {
    grid.SetFocusedRowIndex(e.visibleIndex);
}
csharp
protected void ASPxGridView2_BeforePerformDataSelect(object sender, EventArgs e) {
    Session["CategoryID"] = (sender as ASPxGridView).GetMasterRowKeyValue();
}
vb
Protected Sub ASPxGridView2_BeforePerformDataSelect(ByVal sender As Object, ByVal e As EventArgs)
    Session("CategoryID") = (TryCast(sender, ASPxGridView)).GetMasterRowKeyValue()
End Sub

See Also

ASPxClientGridView Class

ASPxClientGridView Members