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
150
AfterSortChange event firing too early?
posted

Good afternoon,

We are trying to apply appearances only to visible rows in our application. This is an "old" application written 10 years ago and some of our customers are now using a grid with 10K recors or more. The original implementors did not anticipate this situation and were applying conditional formatting to all 10K+ rows on a regular basis (potentially every 10s).

We have found a nice way to apply appearances (based on somewhat complex business rules) in an asynchronous fashion so the evaluation of the whether or not to apply a different appearance is all done on a background thread (and potentially in parallel). We had to subscribe to a handfull of events to properly "paint" our rows when certain aspects of the grid were changed (e.g. AfterRowRegionScroll, AfterRowRegionSize, Resize, AfterRowExpanded).

However, we are running into issues with AfterSortChange event. It does seem to fire too early. What we mean by that is that the event fires but the rows are not sorted with the new sort order. I have attached a quick sample that shows what I mean by that.

The sample will display a simple MessageBox when the AfterSortChange event is raised (change the sort order on the header rows to fire the event). It will then use the DisplayLayout.RowScrollRegions[0].FirstRow to get access to what we are expecting to be the first row in the new order. However, as you will see, it displays the first row in the previous sort order instead.

Our question is whether or not this is expected behavior. If it is, we would welcome any recommendations as to how we could get notified when the visible rows have changed following a change in the sort order (or in general, when those visible rows change so we can respond to this event).

Thanks in advance for your support.

Regards,

Eric.
Note: I have tried this with both 7.2 and 2010.1 with the same outcome.

IgUltraGridAfterSortExample.zip
Parents
No Data
Reply
  • 69832
    Verified Answer
    Offline posted

    The RowScrollRegions are a function of the visual display, so you have to trigger immediate regeneration of the UIElements. Add a call to UltraGrid.DisplayLayout.UIElement.VerifyChildElements, like so:

    private void AfterSortChanged(object sender, BandEventArgs e)
    {
         ultraGrid1.DisplayLayout.UIElement.VerifyChildElements( true );

     UltraGridRow row = ultraGrid1.DisplayLayout.RowScrollRegions[0].FirstRow;
     var dvRow = (DataRowView) row.ListObject;
     var dRow = (DataSet1.MyDataRow) dvRow.Row;
     MessageBox.Show(@"First Row is:" + dRow.Name);
    }

Children
No Data