How to sort records (with code) in a grouped ListGrid?

后端 未结 2 1036
孤城傲影
孤城傲影 2021-01-07 10:26

This is the scenario: I\'m working with a listgrid that needs to be grouped, and also needs to have its records ordered within each group. I\'ve already used the ListG

2条回答
  •  甜味超标
    2021-01-07 11:03

    I have been having a similar issue. Disclaimer: if the "grouping data" message is not appearing when you group then the following solution may not help.

    In my case the sorting of a grouped column was screwed because of the "grouping data" pop up. Let me clarify.

    The "grouping data" pop up appears when trying to group a ListGrid that is displaying more than 50 records.

    It appears because the ListGrid, internally, is doing the grouping operation asynchronously to avoid the "script running slowly" message from the browser.

    What I did was to set the grouping async threshold to a higher value. The risk of doing this is getting the "script running slowly" browser message, even though this is likely to happen only with IE8/9.

    In the end , in the grid constructor, just add (I used 500 as a threshold):

    setInitialSort(new SortSpecifier[] {new SortSpecifier("user", SortDirection.ASCENDING)}));
    setGroupByField("access");
    setGroupByAsyncThreshold(500);
    

    Also set the initial sort and the grouped column as shown above.

    PROGRAMMATICALLY, FIRST SORT, THEN GROUP.

    Hope this helps.

提交回复
热议问题