Populating Column names from AJAX source dynamically
Populating Column names from AJAX source dynamically
Currently I have tried to create my code to use Datatables and it is working for me except the part where I where I wish to populate the columns from a JSON object dynamically, I have searched countless threads and methods to build/convert/create the JSON as an object but datatables will only take if its written within the js document.
$(document).ready(function () {
domLoaders.EICBackup_IndexView(); // misc function
var columns = [{ "sTitle": "ActivityID", "mDataProp": "activityID" }, { "sTitle": "ContactType", "mDataProp": "contactType" }];
var z = [];
var oTable = $('#tblEIC').dataTable({
"bProcessing": false,
"ajax": {
"url": "RESTApi/EICBackup.json/SearchActivities?paramName=ActivityID¶mValue=11",
"dataSrc": ""
},
"aoColumns": columns /* '/RESTApi/EICBackup.json/GetEICProperties' */
});
});
Everything else works, the closest I have gotten is this code and tried even this previous thread which to my understanding is everything I needed to make it work am I missing something the time that thread was discussed?
http://www.datatables.net/forums/discussion/3519/getting-column-names-from-ajax-source
Answers
i got the solution for anyone looking to autopopulate data and columns properly using a json object