Question

I have a RadGrid with a datatable as it's source. I have AllowCustomPaging set to true.

<telerik:RadGrid runat="server" ID="RadGridSearchResults" 
PageSize="50" AllowPaging="true" AllowCustomPaging="true"
OnNeedDataSource="RadGridSearchResults_NeedDataSource" Skin="Default">
<PagerStyle Mode="NextPrevNumericAndAdvanced" />
</telerik:RadGrid>

The code for my code behind method RadGridSearchResults_NeedDataSource just fills and returns a datatable with the following columns:

dataTableSearchResults.Columns.Add("recipeId", typeof(string));
dataTableSearchResults.Columns.Add("ingredientsIds", typeof(string));
dataTableSearchResults.Columns.Add("country", typeof(string));
dataTableSearchResults.Columns.Add("author", typeof(string));
dataTableSearchResults.Columns.Add("style", typeof(string));
dataTableSearchResults.Columns.Add("friendly", typeof(string));
dataTableSearchResults.Columns.Add("name", typeof(string));

Once the RadGrid is databound, I run the following:

var expression = GridGroupByExpression.Parse(
"recipeId [Recipe], count(recipeId) ingredientsIds [Ingredients] 
Group By recipeId");
this.RadGridSearchResults.MasterTableView.GroupByExpressions.Add(expression);
this.RadGridSearchResults.GroupingEnabled = true;

I would expect my radgrid to then look like the one they have here once you click on the 'Group by expression' button:

Instead, it looks like this:

Hosted by imgur.com

Only looking right after I click the 'sort' button:

Hosted by imgur.com

Any clue? I even tried invoking sort manually but that was not successful.

Was it helpful?

Solution

When you add the group expression, do you call the Rebind() method of the grid to refresh its state? This is necessary in case you apply grouping from postback event handler which does not rebind the control implicitly.

Dick

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top