Hello,
I'm using below code (googled), to get the count from Status column. But this is not displaying the count.
JavaScript
$(document).ready(function() {
getCount('Not-Started');
getCount('In Progress');
getCount('On-Hold');
getCount('Completed');
getCount('Cancelled');
$('.card-header').each(function() {
$(this).prop('Counter', 0).animate({
Counter: $(this).text()
}, {
duration: 1500,
easing: 'swing',
step: function(now) {
$(this).text(Math.ceil(now));
}
});
})
});
function getCount(status) {
//console.log(category);
var listName = "Learning";
var query = "$filter=(Status eq '" + status + "')";
var url = _spPageContextInfo.webAbsoluteUrl + "/_api/web/lists/getbytitle('" + listName + "')/items?" + query;
getListItems(url, function(data) {
var items = data.d.results;
$('#' + status).text(items.length);
});
}
function getListItems(siteurl, success, failure) {
$.ajax({
url: siteurl,
method: "GET",
async: false,
headers: {
"Accept": "application/json; odata=verbose"
},
success: function(data) {
success(data);
},
error: function(data) {
failure(data);
}
});
}
0
Not-Started
0
In Progress
0
On-Hold
0
Completed
0
CancelledMy SharePoint List is named as "Learning". And I have below choice options in Status column:
Not-Started
In Progress
On-Hold
Completed
Cancelled
I;m getting the output as below, but no count.



Vaibhav ChauhanRank #963 · 2.1K reputationPosted Jun 18, 2021, 10:24 AM EDT
Vaibhav ChauhanRank #963 · 2.1K reputationPosted Jun 17, 2021, 8:25 AM EDT
Please verify the Jquery and other library path by accessing it in browser tab.
Use below code CDN path for jquery and search for other libraries CDN.
Prem M66 reputationPosted Jun 17, 2021, 9:07 AM EDT
Vaibhav ChauhanRank #963 · 2.1K reputationPosted Jun 17, 2021, 9:12 AM EDT
Prem M66 reputationPosted Jun 18, 2021, 8:50 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 18, 2021, 8:56 AM EDT
Prem M66 reputationPosted Jun 18, 2021, 9:18 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 18, 2021, 9:22 AM EDT
Prem M66 reputationPosted Jun 18, 2021, 9:30 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 18, 2021, 9:33 AM EDT
Prem M66 reputationPosted Jun 18, 2021, 9:58 AM EDT
Still no Luck:
Prem M66 reputationPosted Jun 18, 2021, 10:28 AM EDT
Prem M66 reputationPosted Jun 18, 2021, 10:34 AM EDT
Sachin SinghRank #66 · 26.2K reputationPosted Jun 18, 2021, 10:36 AM EDT
Prem M66 reputationPosted Jun 18, 2021, 10:45 AM EDT