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
1105
Grid Sort
posted

I'm noticing a very odd behavior with column sorting in the grid.  Upfront I will admit we are still on infragistics version 2010.1 (we had a release upcoming and couldn't wait for the multiple group by issue to be fixed)

I have a grid where for one column I have implemeneted a custom grid sorter (of type IComparer) and assigned that to the column's .SortComparer property.

While debugging another operation, I had need to disable all sorting.  So in the grid's _BeforeSortChange event I set e.cancel = true;

When I did so, I noticed that clicking on a column header, while not performing a sort, still seemed to lock the UI thread briefly (for a very large dataset, after clicking the column header I was unable to focus any other component for a few seconds).

I put a breakpoint in Visual Studio in the _AfterSortChange event and never hit it.

However, I also put a breakpoint in my custom sort class's Compare() method and that one gets hit.

It *seems* as if, even though the cancel is set to true in the _BeforeSortChange method and no visual sort is performed, the sorting "logic" is still being performed by the grid.

For the record, I am not calling a RefreshSort() anywhere in the grid or in any other way kicking off a manual sort.

Is this behavior intended?  If so is there some way I can work around it (besides dynamically adding / removing the sort class from the column).

Thanks,

 

Chris Rowland

Parents
No Data
Reply
  • 1105
    posted

    Thanks for the reply Mike.  In putting together a sample app for you to look at I discovered the behavior is a bit different than I described.

    For the sake of the example, consider a scenario where my logic conditionally cancels the beforeSort event, such that one time it may be allowed to continue, other times not.

    It appears that once a column using a GridSorter is sorted, even if every other sort event after that is canceled, the sort logic is still executed.

    Attached is a very simple project containing a grid with 3 columns and 4 rows, and a simple sort comparer class that allows you to sort one column by the values in another.

    The first column "CustNum" contains an instance of this sort comparer so as to sort by the second column "CustName".

    At the class level I have an int counter set to zero.

    In the BeforeSortChange event, if the counter is zero, I *don't* cancel the event and increment the counter, else I cancel.  This mimics the behavior of the first sort being allowed, subsequent sorts canceled.

    I have a Console.Writeline statement in my Sort Comparer's Compare method.

    I expect to see the writeline values on first click of the column header.  I expect to NOT see them on the 2nd and subsequent click, but I do.

    This seems to me to prove that despite canceling the sort event, the sort logic is still being executed.

Children