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.v18.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 Bootstrap Controls BootstrapGridView
.SettingsBehavior.AllowFocusedRow
ASP.NET Web Forms Controls ASPxGridView
.SettingsBehavior.AllowFocusedRow
GridViewProperties
.SettingsBehavior.AllowFocusedRow
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.

WebForms 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

The following code snippet (auto-collected from DevExpress Examples) contains a reference to the AllowFocusedRow property.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also