Ticket T324714
Visible to All Users

WinForms Grid view - Confusion trygin to determine row count, group rows and which rows are expanded/collapsed in the groups

created 9 years ago

Hi, I hope you can help

in my project I am representing some data for a user as per screen shot

This data is grouped on 2 columns (Virtual Shift, which is a date time range from to) and Name , which is a name as shown POS Manager, RRV1 etc

When I have been adding/removing items from the data source I have to do a refresh a force a re-read from the database. this causes the grid to rebuild and consequently loose the topindex and selected row.  I have dealt with this as I did with another grid from a previous support ticket.

Now

my issue is that , if the groups are all expanded then everything is fine, the reset of the top index and focused row handle works fine and the grid is shown correctly , however , if any groups are collapsed It fails to work due to the collapsed rows .

So I started to look into determining which rows are collapsed so I can collapse them after the reload of the data and before I reset the focused row handle.

My issue is this

The row count changes when you collapse rows… and as such m the collapsed rows are not part of the rowcount anymore!

when all rows are visible I have 155 in the rowcount (these represent 120 actual data rows + the group header rows…

when I collapse the top level group row with the shift , I check the rowcount and now its a 3rd less so I can tell by this the rows not visible are no longer in the row count

If I collapse all I see a row count of 3!!

I found an example that shows how to determine group rows and if all are collapsed etc and this example uses the rowcount to determine the loop. this will never work

How should I determine what rows are collapsed (even a loop for 5000 rows does not work because IsGroupRow  and GetRowExpanded does not appear to work.

What am I doing wrong ?

In summary I need to reset the collapsed state of the groups after reloading (I need to record the state before reload and then re-apply this state)

Comments (1)
DL DL
Darren Lawrence 9 years ago

    If I collapse ALL while row count shows 3 , the IsGroupRow(0) or 1 or 2 still all return False! when I would of expected True

    Answers approved by DevExpress Support

    created 9 years ago

    Hello,

    The RowCount property represents the number of visible rows within a View. That's why it changes when you collapse group rows.
    Group rows have handles different from regular rows. For this reason, calling the IsGroupRow(0) method returns false. You can find more information about it in the Process Group Rows documentation article.
    Please review the following Knowledge Base article that provides precise instructions on how to iterate through GroupRows.
    How to traverse grid rows in their visible order
    If this information is not helpful, create a small sample illustrating this issue or modify the sample from the T315522 thread. I hope to hear from you soon.

      Comments (3)
      DL DL
      Darren Lawrence 9 years ago

        I find this subject very un intuitive.  the isGroupRow will always return false for positive handles and true for negative handles… this means the method is useless.
        Having negative numbers to denote grouped rows is very confusing also.  I can see no way to determine the number of group rows (rowcount is only visible rows as stated).  so how do I build details of what rows are collapsed to be able to re-collapse them on reload.
        The KB is not helping me at all.
        My question is still how do I determine which group rows are collapsed, and how can I re-set the collapsed state after reload?!

        DL DL
        Darren Lawrence 9 years ago

          Just to note,
          The sample provided worked perfectly and was just what I was looking for.
          Thanks

          DevExpress Support Team 9 years ago

            Hello,

            I'm happy to hear that the provided sample was suitable. Should you have any questions regarding our products, do not hesitate to contact us.

            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.