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
2387
group by multiple columns
posted

Is there a way to allow a user to have one grouping be multiple columns?

Example:  Categories contain questions (all questions have a category).  Templates are made of one or more questions, the same question can be used on multiple templates, but one template can only contain a question one time.

Dataset:
Category
Question
Template name
Template date

The user might want to group by Category or by Template Name/Template Date.  Is there a way a user can make the group be based on both the Template Name column and the Template Date column?

Sam

Parents
No Data
Reply
  • 469350
    Verified Answer
    Offline posted

    Hi Sam,

    The user can, of course, group by two columns - but then this will create multiple levels of grouping, which is not what you want.

    If you want to create a grouping that is based on the value of two columns, you can do that using the GroupByEvaluator property of the column.

    The way grouping works is that the column is first sorted. Then the grid goes through the rows in order and uses the GroupByEvaluator to determine if the rows belong in the same group. Normally, it does this by comparing the value in the row to the value of the next row, but you can use the GroupByEvaluator to group by any criteria you like. In this case, you will also need a SortComparer to make sure that sorting the column sorts by both fields so that the grouping will work properly.

     

Children