I have a list WSR, there is view in it called 'Overdue'. I want to get the count of the items in this view using javascript. Please help


3 Answers 3


Using Full Rest API

    url: _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('your_list')/items?$select=your_field,Title",
    method: "GET",
    headers: { "accept": "application/json;odata=verbose", },
    success: function (data) {
        var cosa = complete(data.d.results, "SubProcesoId")
    error: function (data) {

function complete(items,propertyName)
    var result = [];
    var obj = {};
    $.each(items, function(index, item) {
        var obj = {};
        obj.subp = item.SubProcesoId;
        obj.title = item.Title;
    return result;

This will return a JSON object with all the elements in the list. Using the underscorejs library, you can group by and get the count per repeted item.

console.log( _.groupBy(orders, function(obj){
    return obj["subp"];

This is the example of my test https://jsfiddle.net/hetdapuv/


When you query the Lists.asmx web services, it's result set XML response already contains the row count in an attribute value of the rs:data element which is what you need if you target the specific view and don't exceed the query RowLimit setting. Otherwise, you'll have to count.

Marc D Anderson's SPServices library now on GitHub has awesome documentation and samples.


If the View is displayed

Add a Content Editor WebPart below the View on the page

and execute:

console.log('There are', ctx.ListData.Row.length,' items in this View (page)');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.