Ticket T576131
Visible to All Users

Detail View Row disappears after adding

created 7 years ago

Hi

I am having one winform grid with Master details view. When I add new master row and save it and then add detail row, it works as expected But when I try to add new master row and detail row at same time, detail row gets disappear after save. I have to expand and collapse master row to see the detail row in grid.

Show previous comments (1)
CS CS
Chetan Shinde 1 7 years ago

    Hi,

    I am using DataSet for this purpose. I have 2 table in dataset and parent child relationship on tables. I am able to see master details view in grid and grid is editable. When I try to insert Master and details at same time, after save details row get invisible and it gets visible after collapse and expansion of master row. Data gets saved in database but this change is not reflection in grid unless master row collapse and expand.

    DevExpress Support Team 7 years ago

      Hi,

      Showing a new detail row should not depend on saving changes to your data base since this operation does not influence the grid. Would you please clarify if you fetch data from your data base again after saving the changes and re-set the grid's data source?

      In any case, I have created a small project with two master and detail tables. If I add new master and detail rows at the same time, everything operates as expected. Please modify my project to show how to reproduce the shortcoming.

      I look forward to your response.

      CS CS
      Chetan Shinde 1 7 years ago

        Hi,

        Please see attached project. When I modified ID on click of another button child row disappears. PLease add one row and then click on new button added by me. I am modifying ID column here. In my project case as well, ID changes after data saved and return by database.
        Hope its clear no

        Answers approved by DevExpress Support

        created 7 years ago

        Hi,

        I see this behavior. Since at this time detail data still contains an old ID value, the detail rows are hidden until you re-expand a corresponding master row. To update detail data immediately without hiding them, I suggest that you re-expand the master row in code:

        C#
        private void simpleButton2_Click(object sender, EventArgs e) { int dataSourceRowIndex = 0; masterTable.Rows[dataSourceRowIndex]["ID"] = 10; int rowHandle = gridView1.GetRowHandle(dataSourceRowIndex); if (gridView1.GetMasterRowExpanded(rowHandle)) { gridView1.SetMasterRowExpanded(rowHandle, false); gridView1.SetMasterRowExpanded(rowHandle, true); } }

        Let me know if this approach is suitable.

          Comments (2)
          CS CS
          Chetan Shinde 1 7 years ago

            Hi,

            This solution will work. But what if I have multiple new Master details rows. Then I have to iterate each and every master row to check it its expanded then collapse and expand again.

            DevExpress Support Team 7 years ago

              First, let me explain why this behavior occurs. When you expand a master row, we access corresponding data by using the standard PropertyDescriptor.GetValue method. This method will return a new RelatedView object containing detail data. When you change a value of the primary parent column, the underlying DataTable starts updating its related data. Thus, it removes your new row from the existing RelatedView since this row's foreign key value does not correspond to the parent value. In turn, GridControl receives a notification that the row was removed from the detail data source. Thus, it refreshes its content, and now the detail view shows nothing. When you re-expand the master row, the PropertyDescriptor.GetValue method is called again and a new RelatedView object is created. At this time, this RelatedView contains the updated data.

              As for the solution, you can learn how to traverse through all the master rows by reviewing the Expanding/Collapsing All The Master Rows help article.

              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.