I'm trying to use DataTables server-side processing piece but I'm having trouble wiring it up.
FYI, the custom API that I'm using is SharePoint 2010 client-side object model (ecmascript). SharePoint also has a REST API but it would not be as efficient in my case.
I have a large set of data which means that I can only pull pages at a time. I know how to pull all this information but I just can't seem to wire it up to the datatable because my JSON isn't in the best format and I have to make my own call to get the following JSON:
The items that I want to display in the datatable are in the _Child_Items_ object so I can map this into an array of object which would be easier to work with.
I want to do something similar to (http://datatables.net/usage/server-side)
My problem with this above is that I don't have an sAjaxSource per se. I wan't to call my own methods.
So my main question is:
If I can get it into an array how do I tell datatable to make another ajax call for example to get another page?
Basically I need a hook for the following:
1. initial getting of data (ajax call)
2. display data when ajax suceeds
3. filtering (another ajax call)
4. paging (another ajax call)
FYI, the custom API that I'm using is SharePoint 2010 client-side object model (ecmascript). SharePoint also has a REST API but it would not be as efficient in my case.
I have a large set of data which means that I can only pull pages at a time. I know how to pull all this information but I just can't seem to wire it up to the datatable because my JSON isn't in the best format and I have to make my own call to get the following JSON:
[ { "SchemaVersion":"14.0.0.0","LibraryVersion":"14.0.6108.5000","ErrorInfo":null },22,{ "IsNull":false },24,{ "IsNull":false },26,{ "IsNull":false },28,{ "IsNull":false },29,{ "_ObjectIdentity_":"740c6a0b-85e2-48a0-a494-e0f1759d4aa7:web:c0db73c7-84d7-42c3-b54a-0e664fddc6e1:list:c14a8f23-3f70-4f38-99a9-b0a07d9de3f6" },31,{ "IsNull":false },32,{ "_ObjectType_":"SP.List","_ObjectIdentity_":"740c6a0b-85e2-48a0-a494-e0f1759d4aa7:web:c0db73c7-84d7-42c3-b54a-0e664fddc6e1:list:c14a8f23-3f70-4f38-99a9-b0a07d9de3f6","_ObjectVersion_":"9","ParentWebUrl":"\u002fproj\u002fdits","HasExternalDataSource":false,"Created":"\/Date(1350326545000)\/","LastItemModifiedDate":"\/Date(1350329404000)\/","LastItemDeletedDate":"\/Date(1350326545000)\/","Id":"\/Guid(c14a8f23-3f70-4f38-99a9-b0a07d9de3f6)\/","Description":"","Title":"Branches","Direction":"none","BaseType":0,"ImageUrl":"\u002f_layouts\u002fimages\u002fitgen.png","ItemCount":73,"BaseTemplate":10023,"DefaultContentApprovalWorkflowId":"\/Guid(00000000-0000-0000-0000-000000000000)\/","TemplateFeatureId":"\/Guid(0212e84c-da95-4561-880e-01582434f16e)\/","DefaultViewUrl":"\u002fproj\u002fdits\u002fLists\u002fBranches\u002fAllItems.aspx","DefaultEditFormUrl":"\u002fproj\u002fdits\u002fLists\u002fBranches\u002fEditForm.aspx","DefaultNewFormUrl":"\u002fproj\u002fdits\u002fLists\u002fBranches\u002fNewForm.aspx","DefaultDisplayFormUrl":"\u002fproj\u002fdits\u002fLists\u002fBranches\u002fDispForm.aspx","EnableAttachments":true,"ServerTemplateCanCreateFolders":true,"EnableFolderCreation":false,"EnableModeration":false,"EnableVersioning":false,"ForceCheckout":false,"EnableMinorVersions":false,"DraftVersionVisibility":0,"Hidden":false,"IsApplicationList":false,"IsCatalog":false,"AllowContentTypes":true,"DocumentTemplateUrl":null,"ContentTypesEnabled":true,"MultipleDataList":false,"NoCrawl":false },33,{ "_ObjectType_":"SP.ListItemCollection","_Child_Items_":[ { "_ObjectType_":"SP.ListItem","_ObjectIdentity_":"740c6a0b-85e2-48a0-a494-e0f1759d4aa7:web:c0db73c7-84d7-42c3-b54a-0e664fddc6e1:list:c14a8f23-3f70-4f38-99a9-b0a07d9de3f6:item:4,1","_ObjectVersion_":"1","Id":4,"DisplayName":"branch 2","DITSDivision":{ "_ObjectType_":"SP.FieldLookupValue","LookupId":5,"LookupValue":"division 2" } },{ "_ObjectType_":"SP.ListItem","_ObjectIdentity_":"740c6a0b-85e2-48a0-a494-e0f1759d4aa7:web:c0db73c7-84d7-42c3-b54a-0e664fddc6e1:list:c14a8f23-3f70-4f38-99a9-b0a07d9de3f6:item:13,1","_ObjectVersion_":"1","Id":13,"DisplayName":"branch 1","DITSDivision":{ "_ObjectType_":"SP.FieldLookupValue","LookupId":6,"LookupValue":"division 1" } } ] } ]
The items that I want to display in the datatable are in the _Child_Items_ object so I can map this into an array of object which would be easier to work with.
I want to do something similar to (http://datatables.net/usage/server-side)
fnServerData
This parameter allows you to override the default function which obtains the data from the server ($.getJSON) so something more suitable for your application. For example you could use POST data, or pull information from a Gears or AIR database.
$(document).ready( function() { $('#example').dataTable( { "bProcessing": true, "bServerSide": true, "sAjaxSource": "xhr.php", "fnServerData": function ( sSource, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { "dataType": 'json', "type": "POST", "url": sSource, "data": aoData, "success": fnCallback } ); } } ); } );
My problem with this above is that I don't have an sAjaxSource per se. I wan't to call my own methods.
So my main question is:
If I can get it into an array how do I tell datatable to make another ajax call for example to get another page?
Basically I need a hook for the following:
1. initial getting of data (ajax call)
2. display data when ajax suceeds
3. filtering (another ajax call)
4. paging (another ajax call)