Sorting is one of the important features that are nearly always required in each project. Recently I’ve run into a major problem on a Sitecore / .NET project, when displaying a set of data that was sorted. Actually the sorting wasn’t any problem, no it was the differende between the two ways that the data was retrieved:
In one situation the data was retrieved by using the Children.ToArray() statement:
Item[] lChildrenItemArray = Sitecore.Context.Item.Children.ToArray();
In the other situation the data was retrieved by using a Xpath Query:
Item[] lChildrenItemArray = Sitecore.Context.Item.Axes.SelectItems(@"descendant::*[@@templatename='News']")
Ofcourse there is a difference in de two statements, in the second one we are applying a restriction that the selected items have to be based upon the ‘News’ template. But I swear to god that all the items that are children of the Sitecore.Context.Item, in the first situation, where based upon this template.
- The first statement gave a resultset of 200+ records.
- The second one only gave a resultset of 100 records.
So there had to be a setting that applies a restriction to the resultset. And yes, stop looking any further, cause here is the answer (found on http://sdn5.sitecore.net/FAQ/API/Item%20Limit%20in%20a%20Multilist.aspx ):
<!-- Query.MaxItems
Specifies the max number of items in a query result set. This also controls the number of items in Lookup, Multilink and Valuelookup fields. -->
Use the Query.MaxItems web.config setting to set necessary item quantity:
<setting name="Query.MaxItems" value="1000" />
When using a Xpath Query be aware that there’s a config option for the number of results returned!
Hope this is usefull!
Gr.
Robbert