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

My grid has the following columns:

Codenumber | Price | Component | Qty

123                  10        ABC             1

123                  10        DEF              2

123                  10        GHI                3

456                   50        JKL               4

456                   50        MNO             5

I need to group by codenumber and price, but they should both be on the same line. It shouldn't go from Codenumber down to price and then down to component and qty. Codenumber and price should be 1 group.

I also need to do this in code since I am supplying the datasource at runtime and can have different columns. Depending on the columns I may not want to group it this way.

Is there some kind of property to set this or code that can group it this way?

I appreciate any help. Thank you.

Parents
  • 469350
    Verified Answer
    Offline posted

    The easiest way to handle this would be to use an unbound column. What you would do is use the InitializeLayout event of the grid to add a column to the root band. You can make the DataType of this column anything you want, but I would probably use a string, and then you can populate the column with values containing what you want displayed in the GroupByRow.

    Then you group the grid by the unbound column (also in InitializeLayout).

    Then you would use the InitializeRow event to populate the unbound column with the combined values of the Codenumber and Price columns.

Reply Children