Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
205
FixedRows Collection Cleared after Grouping
posted

Dear All,

In order to have a permanent, clickable 'footer' in my grid, I'm creating a dummy row in my data and - in the InitializeRow event - setting the Fixed property of the corresponding grid row to true.

The issue I'm having is that the FixedRows collection is cleared as soon as the user performs a group-by, and when they return to 'normal' view (i.e. non-grouped), InitializeRow doesn't fire and therefore my fixed row isn't restored.

Could anyone be so kind as to suggest a means by which I can restore the fixed row following a group-by?  Unlike InitializeRow, InitializeRowsCollection does at least fire when the grid reverts to its normal view, after a group-by.  Would writing a handler for this event be the best way to reliably restore the fixed row?

Many thanks in advance,

James

 

  • 5118
    Verified Answer
    posted

    Hi James,

    The grid does not track the row.fixed property in a way that would be remembered through grouping.  So if you perform a GroupBy the row.Fixed property (all the rows for that matter) is/are destroyed.  So when you ungroup there are no rows with a Fixed value of true.  

     

    My workaround is similar to what you suggest as shown in the attachment with some checks and code inside InitializeRowsCollection.  You can see the comments inside InitializeRowsCollection for more detail.   

     

    WinGridFixedRowAndGrouping.zip
    • 205
      posted in reply to Matthew Kraft

      Hi Matthew,

      A most insightful (and undeniably superior :)) alternative to the approach I took.  Many thanks for your help!

      James

       

      • 205
        posted in reply to Matthew Kraft

        There's one final requirement that I'd like to implement, though I have doubts as to its feasibility.  Basically, I'd like the footer I described in my first post to be present even when the grid's in group-by mode.

        The perfect solution would, of course, be to for the groups to display as usual, with the fixed dummy data row appearing beneath or over them as required.  I suspect, however, that such behaviour goes against the notion of grouping to such an extent that I'd have to alter some private or internal methods within WinGrid to achieve it, something that I'm not prepared to do.

        The next best solution would be to create an extra group-by row during each grouping operation, then add that row to the collection of GB rows that the grid supplies.  I've confirmed that group-by rows can be fixed, so if I were able to generate a custom GB row I could show it as a footer.  However, grid display becomes slightly erratic when a fixed GB row is expanded.  Therefore, the GB row that I generate would need either to 1) have no child rows (flying in the face of the concept of grouping yet again), or 2) be non-expandable.

        Does anyone happen know if either of these approaches are feasible?  If not, I'll attempt the third best and simplest option: highlight the GB row that contains the dummy row, then have all clicks on that GB row activate the dummy row within.  Unfortunately, in this scenario,  I'm unable to fix the highlighted GB row because, as mentioned earlier, expanding a fixed GB row results in a slightly odd display.

        I fully appreciate that I'm looking for the grid to do something it was never (and should never have been) designed to do; but any advice I receive would be very gratefully accepted.

        Many thanks in advance,

        James

        • 5118
          posted in reply to James

          Be sure to heed the comments in the project though... if you are sorting and whatnot then we need to go about the checks a little different. 

          There are always 1001 ways to get the job done and one way does not necessarily have to better than the other. 

      • 205
        posted

        Handling InitializeRowsCollection as below seems to do the trick

         foreach (UltraGridRow r in e.Rows)
         if (r.IsDataRow && !(r.HasParent() && r.ParentRow.IsGroupByRow))
          r.Refresh(RefreshRow.FireInitializeRow);
         else
          break;

         

         

         Apologies - I should have thought the problem through myself before wasting anyone's time.

        Cheers,

        James