ASPxGridViewBehaviorSettings.AllowFocusedRow Property
Gets or sets whether the focused row is displayed.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v21.2.dll
NuGet Package: DevExpress.Web
Declaration
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:
Object Type | Path to AllowFocusedRow |
---|---|
ASPxGridView |
|
GridViewProperties |
|
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()