Reputation: 334
I've seen you can do GroupByExpressions on Telerik's RadGrid like this:
<GroupByExpressions>
<telerik:GridGroupByExpression>
<SelectFields>
<telerik:GridGroupByField FieldAlias="Received" FieldName="Received" FormatString="{0:D}"
HeaderValueSeparator=" from date: "></telerik:GridGroupByField>
</SelectFields>
<GroupByFields>
<telerik:GridGroupByField FieldName="Received" SortOrder="Descending"></telerik:GridGroupByField>
</GroupByFields>
</telerik:GridGroupByExpression>
</GroupByExpressions>
But I'm trying to group employees from code. I've tryed this (employeelist have 27 rows):
Telerik.Web.UI.GridGroupByExpression groupby = new Telerik.Web.UI.GridGroupByExpression();
groupby.SelectFields.FindByName("EmployeeSoc");
groupby.GroupByFields.FindByName("EmployeeSoc");
gridEmployees.MasterTableView.GroupByExpressions.Add(groupby);
gridEmployees.PageSize = employeelist.Count();
gridEmployees.DataSource = employeelist;
grdDatos.Rebind();
Nothing goes wrong during the debug, but grid says 'No records to display.'.
Upvotes: 1
Views: 1631
Reputation: 5951
You are trying to do a programmatic definition of a group by expression in RadGrid.
There are three things I see that might be incorrect with the code you have posted. Try to take a look at each and reach a possible solution or move you along past your current error:
You have not defined an Aggregate Function. Each grouping needs to have an aggregate function (Sum, Avg, Max, Min, etc)
Your list is not wired into your RadGrid correctly. When I see the error
No records to display
this is means no rows from the List are displayed regardless of the groupings. Remove the grouping code and get the employees displaying correctly without groupings in your RadGrid.
SelectField
"EmployeeSoc" is the same as your GroupByField
. This is okay to do - but typically one likes to group one column against the other. (Price per Product, or Average Age per category, etc) Please post your data model in your question and your grouping goal from a requirements perspective with EmployeeList and we can try to help you further.
Upvotes: 1