ajax - How to replace the Data Array in jQuery DataTables -
i have datatables table filled json array (directly written html asp.net). want refresh data ajax data won't added. want use own method, not datatables' internal ajax method. (using datatables 1.10.0).
$.getjson("?ajax=1", null, function(json, status, xhr) { var table = $("#" + protableid).datatable(); osettings = table.settings(); //table.clear(); table.rows().remove(); var data = table.data(); (var = 0; < json.length; i++) { data.push(json[i]); } table.draw(); });
the json result correct after call datatable empty. how replace data inside datatables object , preferably keep sorting , filtering?
for adding data data table, have access property row of data table object, , call add method. finally, update table calling draw method.
as can seen on data table documentation. have this:
for(var i= 0; < json.length; i++){ table.row.add([ json[i].firstproperty, json[i].secondproperty ]).draw(); }
Comments
Post a Comment