在单击排序网格按钮之前,Rad Telerik GridGroupByExpression 不会分组
我有一个带有数据表的 RadGrid 作为它的源。 我已将AllowCustomPaging 设置为true。
<telerik:RadGrid runat="server" ID="RadGridSearchResults"
PageSize="50" AllowPaging="true" AllowCustomPaging="true"
OnNeedDataSource="RadGridSearchResults_NeedDataSource" Skin="Default">
<PagerStyle Mode="NextPrevNumericAndAdvanced" />
</telerik:RadGrid>
我的代码背后的方法 RadGridSearchResults_NeedDataSource 的代码只是填充并返回一个包含以下列的数据表:
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));
一旦 RadGrid 进行数据绑定,我将运行以下命令:
var expression = GridGroupByExpression.Parse(
"recipeId [Recipe], count(recipeId) ingredientsIds [Ingredients]
Group By recipeId");
this.RadGridSearchResults.MasterTableView.GroupByExpressions.Add(expression);
this.RadGridSearchResults.GroupingEnabled = true;
我希望我的 radgrid 看起来像他们 此处:
相反,它看起来像这样:
仅在单击“排序”按钮后立即查看:
有任何线索吗? 我什至尝试手动调用排序,但没有成功。
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:
Only looking right after I click the 'sort' button:
Any clue? I even tried invoking sort manually but that was not successful.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
添加组表达式时,是否调用网格的Rebind()方法来刷新其状态? 如果您从回发事件处理程序应用分组,而该处理程序不会隐式重新绑定控件,则这是必要的。
迪克
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