The requested page is not available for the requested platform. You are viewing the content for Default platform.

ASPxClientGridView.SetFocusedRowIndex(visibleIndex) Method

Moves focus to the specified row.

Declaration

SetFocusedRowIndex(visibleIndex: number): void

Parameters

Name Type Description
visibleIndex number

An integer value that specifies the focused row's index.

Remarks

The focused row feature is enabled when the ASPxGridViewBehaviorSettings.AllowFocusedRow property is set to true.

When row focus changes, the ASPxClientGridView.FocusedRowChanged event is raised.

For more information, see Focus and Navigation.

Examples

By default, a master row is not focused when a user clicks the Expand Detail Row icon. To accomplish this task, handle the DetailRowExpanding event and focus a row using the SetFocusedRowIndex(visibleIndex) method.

<script type="text/javascript">
    function OnDetailRowExpanding(s, e) {
        grid.SetFocusedRowIndex(e.visibleIndex);
    }
</script>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="dsMain"
    ClientInstanceName="grid" KeyFieldName="CategoryID">
    <SettingsBehavior AllowFocusedRow="true" />
    <SettingsDetail ShowDetailRow="True" AllowOnlyOneMasterRowExpanded="true" />
    <ClientSideEvents DetailRowExpanding="OnDetailRowExpanding" />
    <Columns>
        <dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
            <EditFormSettings Visible="False" />
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1">
        </dx:GridViewDataTextColumn>
        <dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2">
        </dx:GridViewDataTextColumn>
    </Columns>
    <Templates>
        <DetailRow>
            <dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False" DataSourceID="dsDetail"
                KeyFieldName="ProductID" OnBeforePerformDataSelect="ASPxGridView2_BeforePerformDataSelect">
                <Columns>
                    <dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
                        <EditFormSettings Visible="False" />
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="SupplierID" VisibleIndex="2">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="3">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="QuantityPerUnit" VisibleIndex="4">
                    </dx:GridViewDataTextColumn>
                    <dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="5">
                    </dx:GridViewDataTextColumn>
                </Columns>
            </dx:ASPxGridView>
        </DetailRow>
    </Templates>
</dx:ASPxGridView>
<asp:SqlDataSource ID="dsMain" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
    <SelectParameters>
        <asp:SessionParameter Name="CategoryID" SessionField="CategoryID" Type="Int32" />
    </SelectParameters>
</asp:SqlDataSource>
See Also