简体   繁体   English

将结果分成组

[英]splist results into groups

I've got a basic query to return splist items but I would like to further categorize them to display them in groups(Corporate, ICT, Performance). 我有一个基本查询来返回splist项目,但我想进一步对它们进行分类以按组(公司,ICT,性能)显示它们。 The Group values are stored in column named TeamDivison on the same list. 组值存储在同一列表上名为TeamDivison的列中。 Im trying to make this efficient as possible. 我试图使这一效率尽可能高。 Thanks 谢谢

 SPQuery query = new SPQuery();
 string filter = "Team";

            query.Query = "<Where><Eq><FieldRef Name='Template'/><Value Type='String'>" + filter + "</Value></Eq></Where>";

            SPListItemCollection items = list.GetItems(query);

            foreach (SPListItem item in items) 
            {
                if (items != null)
                {
                // Check team division column, put into appropriate group(Corporate, ICT, Performance). 
                }
            }

If you are using SPGridView, you can achieve the grouping by the below code 如果使用的是SPGridView,则可以通过以下代码实现分组

spgridview.AllowGrouping = true;
spgridview.AllowGroupCollapse = true;
spgridview.GroupField = "TeamDivison";
spgridview.GroupDescriptionField = "TeamDivison";
spgridview.GroupFieldDisplayName = "TeamDivison";

else, This article might be useful for you, http://tarunaverma.wordpress.com/2012/03/18/caml-query-for-group-by-count-and-data/ 否则,本文可能对您有用, http://tarunaverma.wordpress.com/2012/03/18/caml-query-for-group-by-count-and-data/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM