$skip does not work in SharePoint 2013 OData REST Endpoint for list item retrieval


This came as a surprise to me seeing the OData URI query option “$skip” does not work, while trying to implement pagination logic on list using SharePoint 2013 REST API. Although this works perfectly well with the old ListData.svc…:(

So here are some alternatives that can help you in your paginations:

1. Using $filter URI query option:

/_api/web/Lists/GetByTitle(‘ODataList’)/items?$filter=Id gt {SkipValue}&$top={TopValue}

ex. /_api/web/Lists/GetByTitle(‘ODataList’)/items?$filter=Id gt 2&$top=3  –>gives you the records with IDs 3,4,5.

2. Using the _next link at the end of the response

/_api/web/Lists/GetByTitle(‘ODataList’)/items?$top={TopValue}

ex. /_api/web/Lists/GetByTitle(‘ODataList’)/items?$top=10 –> gives you records with Skip and top value as 10. If you go to the end of the response, you will get the “nextlink” in the following format:

<link rel=”next” href=”{Server URL}/_api/web/Lists/GetByTitle(‘ODataList’)/items?%24skiptoken=Paged%3dTRUE%26p_ID%3d5&amp;%24filter=Id+gt+2&amp;%24top=3″ />

But the skipvalue for pagination is taken as the value give for $top parameter.

3. Use the ListData.svc

/_vti_bin/ListData.svc/ODataList?$skip=2&$top=1&$orderby=Id

skip and top works perfectly here and the response is in the AtomPub format.

Bottom line: $skip won’t work with the new SP 2013 REST endpoints for list item retrievals. You will have to go with one of the alternatives above. 

Hope this was helpful.

CSS shortcuts


Using shortcuts in css, makes your CSS look neat, clean and compressed. It should be always taken into account that, you cannot simply play around with shortcuts. Different browsers, behave differently to the shortcuts.

Following are some of the simple and effective shortcuts that i use in my css:

Using Zeros :You need not mention any units with zero’s, be it pt, px, em or any other measurement types.

Normal Method – #spcborder{ border:1px 0px 0px 2px;}

Shortcut Method – #spcborder{ border:1px 0 0 2px;}

Value Shortening : This is normally done with hex color codes.

Normal Method – h1{ color:#333333; border-color:#335577;}

Shortcut Method – h1{ color:#333;border-color:#357;}

One line coding : I would recommend this approach for selectors with atmost 3 properties and non lengthy.

Normal Method

h1{

color:#333333;

border-color:#335577;

font-size : 12px;

}

Shortcut Method – h1{ color:#333;border-color:#357; font-size : 12px;}

Property Grouping : This can be used mostly when you use the grouped properties in css, like border, background,margin, padding etc.

Normal method – div.main{padding-top:2px; padding-right:3px; padding-bottom:2px; padding-left:3px;}

Shortcut method – div.main{padding:2px 3px 2px 3px;}

Further compressing – div.main {padding:2px 3px;}

Another scenario

Normal method – div.main{padding-top:2px; padding-right:3px; padding-bottom:2px; padding-left:3px;}

Shortcut method – div.main{padding:2px 3px 2px 3px;}

Further compressing – div.main {padding:2px 3px;}

The trick here is to use:

  • TOP RIGHT BOTTOMLEFT approach on any such grouped properties, if there are 4 values grouped.
  • TOP & BOTTOMRIGHT & LEFT approach on any such grouped properties, if there are 2 values grouped.
  • In case of 3 valued groups, keep in mind the cyclic order of  TOP RIGHT BOTTOMLEFT . The one missing would take the value of the respective pair, in the grouping.

padding:2px 3px 5px; would imply a padding:2px 3px 5px 3px; The last value (left) is implicit and equals to the value of right.

These shortcuts work easily independent of any browser. It would be good if you use these css shortcuts in your stylesheet.