Skip to main content
Tab

ASPxGridViewBehaviorSettings.AllowFocusedRow Property

Specifies whether row focus is enabled.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v23.2.dll

NuGet Package: DevExpress.Web

Declaration

[DefaultValue(false)]
public bool AllowFocusedRow { get; set; }

Property Value

Type Default Description
Boolean false

true to enable row focus; otherwise, false.

Property Paths

You can access this nested property as listed below:

Object Type Path to AllowFocusedRow
ASPxGridView
.SettingsBehavior .AllowFocusedRow
GridViewProperties
.SettingsBehavior .AllowFocusedRow

Remarks

Set the AllowFocusRow property to true to enable row focus. When focus changes, the control raises the server ASPxGridView.FocusedRowChanged or the client ASPxClientGridView.FocusedRowChanged event (based on the ProcessFocusedRowChangedOnServer property value) and sets the FocusedRowIndex property to the index of the focused row.

The control can focus only one row at a time within the current page. If you navigate to another page, the row loses focus. To select multiple rows within different pages, use row selection.

When row focus is disabled, the control behaves as follows:

  • The FocusedRowIndex property returns -1.
  • The FocusedRowChanged event does not fire.
  • Focused row style settings are not in effect.

To identify the row being edited, use the EditingRowVisibleIndex property.

Limitations

Web Forms Example

The examples below show how to use the AllowFocusedRow property.

<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" KeyFieldName="ProductID"
                AutoGenerateColumns="False">
                <Columns>
                    <%--...--%>
                </Columns>
            </dx:ASPxGridView>
        </DetailRow>
    </Templates>
</dx:ASPxGridView>
function OnDetailRowExpanding(s, e) {
    grid.SetFocusedRowIndex(e.visibleIndex);
}

MVC Example

@Html.DevExpress().GridView(settings => {
    settings.Name = "GridView";
    settings.CallbackRouteValues = new { Controller = "Home", Action = "GridViewPartial" };
    settings.SettingsPager.PageSize = 5;

    settings.KeyFieldName = "EmployeeID";
    settings.Columns.Add("LastName");
    settings.Columns.Add("FirstName");
    settings.Columns.Add("City");
    settings.Columns.Add("Country");

    settings.PreRender = (s, e) => {
        var sender = (MVCxGridView)s;
        // Set the zero-based index of the focused row. 
        sender.FocusedRowIndex = 6;
    };
    // Enable row focus. 
    settings.SettingsBehavior.AllowFocusedRow = true;
}).Bind(Model).GetHtml()
See Also