ASPxGridViewBehaviorSettings.AllowFocusedRow Property
Specifies whether row focus is enabled.
Namespace: DevExpress.Web
Assembly: DevExpress.Web.v24.2.dll
Declaration
Property Value
Type | Default | Description |
---|---|---|
Boolean | false |
|
Property Paths
You can access this nested property as listed below:
Object Type | Path to AllowFocusedRow |
---|---|
ASPxGridView |
|
GridViewProperties |
|
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
When cell merge is enabled, ASPxGridView does not support row focus.
For the ASPxGridLookup control, the
AllowFocusedRow
property is always set totrue
.
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()