How can i use ajax ,data filter outside datatable there is any api ??
How can i use ajax ,data filter outside datatable there is any api ??
ShaikhAhmed
Posts: 2Questions: 1Answers: 0
My table columns generate by dynamically .. i want to map my json response with datatable
- how can i use Ajax dataFilter: function(data){} outside my Ajax request.
- i want to use this AJAX method in my code where i put this
dataFilter: function(data){
var json = jQuery.parseJSON( data );
var resellerreponce = json.searchResults;
json.data = resellerreponce.List;
json.recordsFiltered = resellerreponce.sCount;
json.recordsTotal =resellerreponce.ResultsCount;
return JSON.stringify( json );
}
// This is my actual code for dynamic columns
$.ajax({
url: "Abc.do?action=Items",
success: cb_func
});
});
function getData(cb_func) {
getData(function (data) {
Jdata = data.searchResults.Summary;
var columnNames = Object.keys(Jdata[0]);
for (var i in columnNames) {
columns.push({
data: columnNames[i],
title: columnNames[i]
});
$('#example').DataTable({
data: Jdata,
columns: columns
});
});
This discussion has been closed.