Hi,
I have a SharePoint List which is used to store the information of course enrollment.
What i am looking for is to get the count and name of Course for which maximum people have enrolled?
- Edited by NirajZ Monday, August 17, 2015 1:30 PM
Technology Tips and News
Hi,
I have a SharePoint List which is used to store the information of course enrollment.
What i am looking for is to get the count and name of Course for which maximum people have enrolled?
Hi Prasath,
I know creating a view will give me count, what i am looking for is:
to get the count and name of Course for which maximum people have enrolled? and i will use this information on front end for further process.
Please elaborate your approachHi,
We can use REST API to get all the list item, then use JavaScript to group by the data. The following code for your reference:
<script src="http://code.jquery.com/jquery-1.11.3.min.js" type="text/javascript"></script> <script type="text/javascript"> $(function () { var siteURL = _spPageContextInfo.webAbsoluteUrl; var listname = "CustomList"; var url = siteURL + "/_api/web/lists/getbytitle('" + listname + "')/items?$select=Title"; $.ajax({ url: url, method: "GET", headers: { "Accept": "application/json; odata=verbose" }, success: function (data) { var arr=new Array(); var items = data.d.results; for(var i = 0; i < items.length;i++) { arr.push(items[i].Title); } // group by the data var hist = {}; arr.map(function (a) { if (a in hist) hist[a] ++; else hist[a] = 1; } ); console.log(hist); }, error: function (data) { } }); }); </script>
Best Regards,
Dennis