This is a migrated thread and some comments may be shown as answers.

How to group column from code ?

1 Answer 95 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Krzysztof
Top achievements
Rank 1
Krzysztof asked on 06 Jul 2009, 12:00 PM
Hello.

I have another question I would like to group the table on one of the column. I try to do this using this code, but it's not work:

 

Dim gbe As New GridGroupByExpression("Grupa Group By Grupa")

 

gv_dodatkowe.MasterGridViewTemplate.GroupByExpressions.Add(gbe)


What i'm doing wrong ?

Thanks a lot for help.

1 Answer, 1 is accepted

Sort by
0
Mike
Telerik team
answered on 06 Jul 2009, 02:49 PM
Hi Krzysztof,

You seem to use the correct approach for grouping using code. In this case the only problem I can suspect is that in your case "Grupa" does not refer to any grid columns' UniqueName. Note that RadGrid uses UniqueName property of its columns in the group by, filer or sort expressions.

You may have confused it with the FieldName property. Generally UiqueName is autogenerated baaed on FieldName, but i some cases these two properties can have different values. For example in the case when you have two columns bound to the same data-field.

Another "gotcha" is that RadGridView would not show any error if you try to group by non existing columns, because this feature is designed to work in late-binding scenarios. For example you can add group-by expression first, then grid columns, then data - and this actually happens when you design the grid in Visual Studio. I hope this information was useful and will help you resolve this issue.

Let me know if the problem persists.

Regards,
Mike
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
GridView
Asked by
Krzysztof
Top achievements
Rank 1
Answers by
Mike
Telerik team
Share this question
or