Ticket Q483431
Visible to All Users
Duplicate

We have closed this ticket because another page addresses its subject:

Sub-detail grid collapsing after AcceptChanges

Master rows in a hierarchical XtraGrid are collapsed where I accept the changes on a DataTable

created 12 years ago

Hello,
I have a XtraGrid with hierarchical rows (two levels). The datasource of this grid is a DataTable, which provide master rows. Dynamically, I add detail rows to some master rows (using the events MasterRowGetChildList and MasterRowExpanded of the XtraGrid). The display is OK. However, when I add, modify or delete rows in the DataTable, the write the instruction myDataTable.AcceptChanges() to validate the operations, the master rows expanded are automatically collapsed. Please, can you provide me a solution to keep expanded the master rows when I accept changes on the DataTable ?
Sincerly,

Answers approved by DevExpress Support

created 12 years ago (modified 11 years ago)

Hi,
We have researched this issue and realized that the GridView collapsed its master rows because it received the ListChanged event from the datasource with the ListChangedType.Reset parameter. In this situation, the GridView returns into its initial state. This is the only appropriate reaction to this event, because it is not possible to predict changes made in the datasource.
Thus, this behavior is by design.

To avoid the issue with the GridView row collapsing, you can simply expand a corresponding master row via the GridView.ExpandMasterRow method. Look at the following code:

C#
int iFocusedRowHandle = gridView2.FocusedRowHandle;             ds.AcceptChanges();             gridView2.ExpandMasterRow(iFocusedRowHandle);

The most common approach to saving and restoring the GridView state is described in the following article: How to preserve the XtraGrid View state.

I hope you find this information helpful. Feel free to contact us if you need any further assistance.

    Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

    Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.