ASPxClientGridView.DetailRowExpanding Event
Fires before a detail row is expanded.
Declaration
DetailRowExpanding: ASPxClientEvent<ASPxClientGridViewRowCancelEventHandler<ASPxClientGridView>>
Event Data
The DetailRowExpanding event's data class is ASPxClientGridViewRowCancelEventArgs. The following properties provide information specific to this event:
Property | Description |
---|---|
cancel | Specifies whether to cancel the related action (for example, row edit, export). Inherited from ASPxClientCancelEventArgs. |
visibleIndex | Gets the processed row’s visible index. |
Remarks
Handle the DetailRowExpanding event to specify whether expandeding the detail row is allowed. The detail row currently being processed is identified by its visible index using the ASPxClientGridViewRowCancelEventArgs.visibleIndex property. To cancel this action, set the event parameter’s cancel property to true
.
Example
By default, a master row is not focused when a user clicks the Expand Detail Row icon. To accomplish this task, handle the DetailRowExpanding
event and focus a row using the SetFocusedRowIndex(visibleIndex) method.
<script type="text/javascript">
function OnDetailRowExpanding(s, e) {
grid.SetFocusedRowIndex(e.visibleIndex);
}
</script>
<dx:ASPxGridView ID="ASPxGridView1" runat="server" AutoGenerateColumns="False" DataSourceID="dsMain"
ClientInstanceName="grid" KeyFieldName="CategoryID">
<SettingsBehavior AllowFocusedRow="true" />
<SettingsDetail ShowDetailRow="True" AllowOnlyOneMasterRowExpanded="true" />
<ClientSideEvents DetailRowExpanding="OnDetailRowExpanding" />
<Columns>
<dx:GridViewDataTextColumn FieldName="CategoryID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CategoryName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="Description" VisibleIndex="2">
</dx:GridViewDataTextColumn>
</Columns>
<Templates>
<DetailRow>
<dx:ASPxGridView ID="ASPxGridView2" runat="server" AutoGenerateColumns="False" DataSourceID="dsDetail"
KeyFieldName="ProductID" OnBeforePerformDataSelect="ASPxGridView2_BeforePerformDataSelect">
<Columns>
<dx:GridViewDataTextColumn FieldName="ProductID" ReadOnly="True" VisibleIndex="0">
<EditFormSettings Visible="False" />
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="ProductName" VisibleIndex="1">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="SupplierID" VisibleIndex="2">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="CategoryID" VisibleIndex="3">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="QuantityPerUnit" VisibleIndex="4">
</dx:GridViewDataTextColumn>
<dx:GridViewDataTextColumn FieldName="UnitPrice" VisibleIndex="5">
</dx:GridViewDataTextColumn>
</Columns>
</dx:ASPxGridView>
</DetailRow>
</Templates>
</dx:ASPxGridView>
<asp:SqlDataSource ID="dsMain" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [CategoryID], [CategoryName], [Description] FROM [Categories]">
</asp:SqlDataSource>
<asp:SqlDataSource ID="dsDetail" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
SelectCommand="SELECT [ProductID], [ProductName], [SupplierID], [CategoryID], [QuantityPerUnit], [UnitPrice] FROM [Products] WHERE ([CategoryID] = @CategoryID)">
<SelectParameters>
<asp:SessionParameter Name="CategoryID" SessionField="CategoryID" Type="Int32" />
</SelectParameters>
</asp:SqlDataSource>