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
395
Ultragrid : sort by one column and group by another column
posted

Hello,

I have a datatable as follows:-

QuestionID,QuestionText,QuestionGroup,Sequence.

I want to group this by questionGroup but sort by Sequence ascending.

I did following:-

ultragrid.displaylayout.bands(0).columns("Sequence").sortIndicator = sortindicator.ascending

ultragrid.displaylayout.bands(0).sortedColumns.add("QuestionGroup",false,true)

 

This sorts by Sequence and groups by Question group. But it also sorts by QuestionGroup.

Here is what I have:-

I want General Information group first followed by Billing information followed by Processing Information.

Any idea?

Thank you very much

 

Parents
  • 469350
    Offline posted

    Hi,

    The way grouping works is that the grid must sort the grouped column first. Then it loops through the rows in order and groups rows with the same values that are adjacent.

    So ordinarily, if you sort by one column and then group by another, the groups would not come out right, because you might have the same value in the GroupBy that are no longer adjacent to each other and you would end up with the same group twice.

    From the screen shot you posted here, it looks like in your case, the sequences are the Group are linked in such a way that sorting by sequence would cause all of the groups to end up together.

    If that is the case, then what you could do is write a SortComparer for the Group column which makes it sort by the Sequence and that should do it.

    If your screen shot does not accurately represent all of the data and there are cases where the sequence will be out of order, then what you would need to do is write a GroupBySortComparer to sort the GroupByRows after they are grouped.

Reply Children