I use "Group by" CAML element to group items and also want to applied pagination(10 first grouped items) to SPQuery. But SPList.GetItems(spquery) returned 10 items without grouping them. My code is as follow :
SPQuery spquery = new SPQuery();
SPList spList = ListDAL.GetListByName("PlanIdeas", Constants.EideUrl);
string query = @"<GroupBy Collapse='TRUE' ><FieldRef Name='Plan2PlanIdea' /></GroupBy>";
spquery.Query = query;
if (rowLimit != 0)
{
spquery.RowLimit = rowLimit;
}
if (pageInfo != null && !pageInfo.Equals(""))
{
SPListItemCollectionPosition pos = new SPListItemCollectionPosition(pageInfo);
spquery.ListItemCollectionPosition = pos;
}
SPListItemCollection items = spList.GetItems(spquery);
foreach (SPListItem item in items)
{
var d = new SPFieldLookupValue(item["Plan2PlanIdea"].ToString()).LookupId;
}
How to achieve this by SPQuery and CAML?