在单击排序网格按钮之前,Rad Telerik GridGroupByExpression 不会分组

发布于 2024-08-02 03:29:02 字数 1650 浏览 5 评论 0原文

我有一个带有数据表的 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 看起来像他们 此处

相反,它看起来像这样:

Hosted by imgur.com

仅在单击“排序”按钮后立即查看:

Hosted by imgur.com

有任何线索吗? 我什至尝试手动调用排序,但没有成功。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦里°也失望 2024-08-09 03:29:02

添加组表达式时,是否调用网格的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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文