aspnet-devexpress-dot-web-dot-aspxgridviewbehaviorsettings-73ca24b7.md
Specifies whether row focus is enabled.
Namespace : DevExpress.Web
Assembly : DevExpress.Web.v25.2.dll
NuGet Package : DevExpress.Web
[DefaultValue(false)]
public bool AllowFocusedRow { get; set; }
<DefaultValue(False)>
Public Property AllowFocusedRow As Boolean
| Type | Default | Description |
|---|---|---|
| Boolean | false |
true to enable row focus; otherwise, false.
|
You can access this nested property as listed below:
| Object Type | Path to AllowFocusedRow |
|---|---|
| ASPxGridView |
.SettingsBehavior .AllowFocusedRow
| | GridViewProperties |
.SettingsBehavior .AllowFocusedRow
|
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:
-1.FocusedRowChanged event does not fire.To identify the row being edited, use the EditingRowVisibleIndex property.
When cell merge is enabled, ASPxGridView does not support row focus.
For the ASPxGridLookup control, the AllowFocusedRow property is always set to true.
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);
}
@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
ASPxGridViewBehaviorSettings Class