Grouping event fires too late

Posted by: mikedempsey on 8 September 2017, 12:44 pm EST

  • Posted 8 September 2017, 12:44 pm EST

    I thought that the idea of having a Grouping/Grouped pair of events was that the Grouping event fires BEFORE the model is changed to the GroupDataModel and the Grouped event fires AFTER the change.


    This assumption is reinforced by the fact that Grouping is cancelable, and the fact that the docs describe a number of features that are incompatible with the grouped model and tell me to use the Grouping event to take care of these.


    As a result I added the following to the Grouping event:
    1) Clear all filters
    2) Clear Alternating row colors
    3) Switch off automatic sorting
    4) Remove the last line of the spreadsheet (This contains a 'totals' row)


    The first 3 work fine (either that or the control does these things automatically and simply ignores my commands) but the last one fails.


    The reason it fails is that the GroupDataModel is already in effect and the sheet.rows.count returns zero. (and I can not remove row -1)


    Is the GroupDataModel supposed to be in effect when Grouping fires?


    If so, what event fires BEFORE entering GroupDataModel?
    (I checked Sheet_PropertyChanged [which does fire before Grouping], but even then the model had already been changed)


    Also, if it is supposed to fire after the model change then the documentation needs to be changed to tell you to take care of the 'invalid' items in this other event - not in Grouping. 


    If it is firing incorrectly could that explain my problem with column numbers being displayed on the group rows instead of column names?

  • Replied 8 September 2017, 12:44 pm EST

    Hello,


    The first three things are happening by default. The GroupDataModel is set to the DataModel of the Sheet in the Grouping event, but it has not been set with anything yet. This gives you the ability to initialize the DataModel. You would need to query the TargetModel of the DataModel (if it is a GroupDataModel) to get the DefaultSheetDataModel. Then you can remove a row from this model.

  • Replied 8 September 2017, 12:44 pm EST

    Thanks, that works.


    I thought the documentation meant that the number of rows could not be changed while Grouping was in effect - not simply that you could not use the grouping model to remove the rows.


    BTW - the first 3 things dont really happen automatically.
    Filters are removed automatically but the filter and sort indicators are not.
    And the alternating colors are not removed at all - in fact they appear to work fine in grouping mode - contrary to the docs. (I remove them anyway because they look confusing when rows are grouped.)

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels