aspnet-js-aspxclientgridview-dot-setfocusedrowindex-x28-visibleindex-x29.md
Moves focus to the specified row.
SetFocusedRowIndex(
visibleIndex: number
): void
| Name | Type | Description |
|---|---|---|
| visibleIndex | number |
The row index.
|
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.
<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>
function OnDetailRowExpanding(s, e) {
grid.SetFocusedRowIndex(e.visibleIndex);
}
protected void ASPxGridView2_BeforePerformDataSelect(object sender, EventArgs e) {
Session["CategoryID"] = (sender as ASPxGridView).GetMasterRowKeyValue();
}
Protected Sub ASPxGridView2_BeforePerformDataSelect(ByVal sender As Object, ByVal e As EventArgs)
Session("CategoryID") = (TryCast(sender, ASPxGridView)).GetMasterRowKeyValue()
End Sub
See Also