RadGridView: Order columns by ColumnGroup?

1 Answer 204 Views
GridView
Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
Eldoir asked on 28 Sep 2021, 08:17 AM | edited on 28 Sep 2021, 08:19 AM

Hello,

I'm trying to achieve the following result:

I'm creating my columns and column groups dynamically at runtime.

The thing is, say I'm creating columns in that order:

- Column0, GROUP0

- Column1, GROUP1

- Column2, GROUP0

- Column3, GROUP1

This will result in the following:

How to achieve the result shown in the first screen? (here column0 and column2 would be in GROUP0 and column1 and column3 in GROUP1)

I only want unique column groups, otherwise it doesn't quite make sense.

Thanks!

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 01 Oct 2021, 07:44 AM | edited on 01 Oct 2021, 07:48 AM

Hello Arthur,

In order for the column groups to be rendered as expected, the columns should be ordered by column name. In your example, you will need to add the columns in the following order:

1. Column0 (Group 0)
2. Column2 (Group 0)
3. Column1 (Group 1)
4. Column3 (Group 1)

Note that in this case the column won't be ordered like in your first picture. If you want to achieve this, you will need to move Column1 in Group0 and Column2 in Group1.

I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 04 Oct 2021, 02:47 PM

Hello Martin,

Unfortunately I can't move columns in whatever groups I want since the very purpose of grouping is to organize my columns by meaning. Unless I got you wrong?

Also, since I am creating both my columns AND groups at runtime, I can't order them on the fly to render them as expected because I don't know what will come out next.

Now I'm ordering my columns after I'm done generating everything. Doesn't sound very performant, but it does solve my problem so I will keep it like that for now.

Thanks for your answer!

Martin Ivanov
Telerik team
commented on 07 Oct 2021, 09:42 AM

My previous example was to suggesting to move columns in other groups because this is what the expected picture was showing. In other words, the expected picture and the list of columns/groups wasn't matching. 

Basically, to achieve your requirement you will need to adjust the order of the columns as you are already doing. If you want to avoid performance issues, you can create a list of columns where you can add them during the generation process, then order the list and after this add its columns to the Columns collection of RadGridView.

Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
commented on 07 Oct 2021, 10:14 AM

Great suggestion, thanks!
Tags
GridView
Asked by
Eldoir
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Martin Ivanov
Telerik team
Share this question
or