Skip to main content
A newer version of this page is available. .
Tab

ASPxGridViewBehaviorSettings.AllowFocusedRow Property

Gets or sets whether the focused row is displayed.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v20.2.dll

Declaration

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

Property Value

Type Default Description
Boolean

false

true, to display the focused row; otherwise, false.

Property Paths

You can access this nested property as listed below:

Library Object Type Path to AllowFocusedRow
ASP.NET Controls and MVC Extensions ASPxGridView
.SettingsBehavior.AllowFocusedRow
GridViewProperties
.SettingsBehavior.AllowFocusedRow
ASP.NET Bootstrap Controls BootstrapGridView
.SettingsBehavior.AllowFocusedRow
ASP.NET MVC Extensions GridViewSettings
.SettingsBehavior.AllowFocusedRow
GridViewSettings<RowType>
.SettingsBehavior.AllowFocusedRow
MVCxGridView
.SettingsBehavior.AllowFocusedRow
MVCxGridViewProperties
.SettingsBehavior.AllowFocusedRow

Remarks

If the AllowFocusedRow property is set to false, the focused row feature is disabled. In this instance, the ASPxGridView.FocusedRowIndex property’s value is always -1 and the ASPxGridView.FocusedRowChanged event isn’t raised. The style settings used to paint the focused row are not used. To identify the row currently being edited, use the ASPxGridView.EditingRowVisibleIndex property.

Note

  • The AllowFocusedRow property value is always set to true for the ASPxGridLookup control.
  • The AllowFocusedRow property is not in effect if cell merging is enabled.

Example

The following example illustrates how to use the AllowFocusedRow property.

Web Forms approach:

Note

For a full example, refer to the ASPxGridView - How to sae a focused row index to cookies on the server side online example.

<dx:ASPxGridView ID="gridView" runat="server" AutoGenerateColumns="False" DataSourceID="ads"
    KeyFieldName="CategoryID" ClientInstanceName="gridView" OnDataBound="gridView_DataBound" 
    OnFocusedRowChanged="gridView_FocusedRowChanged">
    <SettingsBehavior AllowFocusedRow="true" ProcessFocusedRowChangedOnServer="true" />
    <Columns>
    ...
    </Columns>
</dx:ASPxGridView>

MVC approach:

@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()

Online Example

See Also