SPGridView 中的组总计
当我使用 GroupField 属性对 SPGridView 中的项目进行分组时,分组效果很好,但总行数不会像标准 SharePoint 列表中那样显示。 通常,SharePoint 会在括号中的组旁边显示计数(即组 1 (5))。 有没有办法启用此功能。
When I group items in a SPGridView using the GroupField property the grouping works great but the total row count does not show up like in a standard SharePoint list. Usually SharePoint will display the count next to the group in parenthesis (i.e. Group 1 (5)). Is there a way to enable this functionality.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
您是否尝试过将
DisplayGroupFieldName
属性设置为True
?SPGridView 类文档
have you tried setting the
DisplayGroupFieldName
property toTrue
?SPGridView class documentation
我快速浏览了代码,甚至覆盖 SPGridview 似乎也没有一个简单的“钩子”来覆盖它。
您也许可以创建 Javascript 来执行此操作,但这一点也不有趣。
I had a quick look at the code and even overriding the SPGridview does not seem to have an easy "hook" to override for this.
You may be able to create Javascript to do this, but it would be far from entertaining.
JavaScript 可以工作了! 纳特的建议帮助了我!
请参阅下面的 jquery 示例:
Javascript works! Nat advice helped me!
See jquery example below:
如果您不想使用 javascript,您可以迭代表并计算每组中的行数。
缺点是您可能需要计算所有行,然后返回并更新每行中的组名称。
例如:
A组2人
B组3名
If you don't want to use javascript, you could iterate through the table and count the rows in each group.
The downside is that you would probably need to count all of the rows and then go back and update the group name in each row.
For example:
2 in GroupA
3 in GroupB
我知道这个问题很老了,但无论如何:
如果你想将它应用到整个页面,你可以 drop.getElementById("your_table") 部分,否则将 gridview 放在具有该 ID 的控件中。
I know this question is old, but anyway:
You can drop.getElementById("your_table") part if you want to apply it to the whole page anyway, otherwise put the gridview in a control with that ID.