Java script to display distinct count of Sharepoint list column values.

Hi 

I want to display distinct count of values in SharePoint list column.

How to achieve this.

Thanks

Siva

May 15th, 2015 1:21pm

This is not complex.

Use case: You have data in a list which needs to be retrieved using JavaScript for those records where Title is unique. <SP URL> is the URL for your SharePoint and <List Name> is the name of your list.

    $.ajax({
        url: <SP URL> + "/_api/web/lists/getbytitle('" + <List Name> + "')/items",
        method: "GET",
        headers: { "Accept": "application/json; odata=verbose" },
        success: function (data) {
            		var result = [], items = data.d;
    			$.each(items, function(index, item) {
       				if ($.inArray(item[propertyName], result)==-1) {
          				result.push(item[propertyName]);
       				}
    			});
    			//work with your results now. This is just a sample
			alert(result.length);
        	},
        error: function (data) {
            alert(data);
        }
    });

Hope this helps
May 16th, 2015 4:13am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics