How to get more than 5000 items from SharePoint List and bind to the Jquery database.
Please find the below code what i written and also i added all JS files(jquery.1.12.min.js,Jquery.DataTable.js, and Jquery.Datatable.css)
I don't understand where i did the mistake i always getting error like DataTable is not a funtion.
Can Anyone please help me on this ASAP.
Thanks in advance....
- </head>
- <Title>
- Threshold more than 5000 items
- </Title>
- <div>
- <table id="CustomerGrid" class="display" cellspacing="0" width="100%">
- <thead>
- <tr>
- <th>ID</th>
- <th>Title</th>
- <th>Requestor</th>
- <th>Company</th>
- </tr>
- </thead>
- </table>
- </div>
- </body>
- <script>
- var web;
- var spItems;
- var position;
- var nextPagingInfo;
- var previousPagingInfo;
-
- var pageIndex = 5;
- var pageSize = 300;
- var Olist;
- var clientcontext;
- var camlQuery;
- var tableContent='';
- var items = [];
-
- $(document).ready(function() {
- clientcontext = new SP.ClientContext.get_current();
- oList = clientcontext.get_web().get_lists().getByTitle("Claims");
- camlQuery = new SP.CamlQuery();
- GetListItems();
-
-
- });
- function GetListItems() {
-
-
- camlQuery.set_listItemCollectionPosition(position);
-
- camlQuery.set_viewXml("<View>" +
- "<ViewFields>" +
- "<FieldRef Name='Title'/>" +
- "<FieldRef Name='Requestor'/>" +
- "<FieldRef Name='Company'/>" +
- "</ViewFields>" +
- "<RowLimit>" + pageSize + "</RowLimit></View>");
- spItems = oList.getItems(camlQuery);
- clientcontext.load(spItems);
- clientcontext.executeQueryAsync(Function.createDelegate(this,this.onSuccess),Function.createDelegate(this,this.onfail));
- }
-
-
- function onSuccess() {
- var listEnumerator = spItems.getEnumerator();
- var item;
- while (listEnumerator.moveNext()) {
- item = listEnumerator.get_current();
- items.push(item.get_fieldValues());
-
- }
- console.log(items);
- try{
-
- $('#CustomerGrid').DataTable({
- "aaData": items,
- "scrollY":"600px",
- "scrollCollapse": true,
- "paging": false,
- "aoColumns":
- [
- {
- "ID":"ID"
- },
- {
- "mData": "Title",
- "render": function(mData,type, full) {
- return '<a href="'+mData+'">' + mData + '</a>';
- }
- },
- {
- "mData": "Requestor"
- },
- {
- "mData": "Company"
- }
- ]
- });
- }
- catch (e) {
- alert(e.message);
- }
-
- managePagerControl();
- }
- function onfail(sender, args)
- {
- alert("fetching failed due to : "+args.get_message());
- }
- </script>