Then came the need to have a nice navigation footer, and I used this component: http://botmonster.com/jquery-bootpag/
This component just needs to know the number of pages and at which page it currently is. But then again, we need to know the number of items to know the number of pages to display. Back at square one ;-)
I looked for ways to implement this once again and found more info this time (technology matured or better search query in Google?). Some articles suggested to force the verbose mode of OData (by using "&$format=verbosejson" or adding an accept header with a value of "application/json;odata=verbose"), to no avail. I would always receive an array with the X items I requested using the $top parameter and nothing else.
Until I came across these 2 posts on SO:
In short, here is what I had to change:
[Queryable(AllowedQueryOptions = AllowedQueryOptions.All)]
IQueryable results = options.ApplyTo(m_oItems.AsQueryable());
return new PageResult
Then in my JS file, I added "&$inlinecount=allpages" to my query and where I would treat the data blob returned by $.getJSON as an array, I simply use data.Count to have the number of items that match my query, and data.Items as my array of items.
The solution looks so simple now, but took me some time to figure out. Hope this helps...
Post a Comment