I am improving with datatables but i need a bit of help.
Maybe i am wrong, but i didnt find datatables examples working with Json data ( from server side processing ) not being the default data ( sEcho, iTotalRecords, iTotalDisplayRecords, aaData, [aoColumns] ) like
I think i know how pass the json, with the new properties data, and change the datatable properties with the new one, but datatable isnt draw/printed/refreshed.
I follow the right steps ?
I will change this code for a function that allow me to parse data from json and store on datatable.oSettings.
I checked JQuery.dataTables.js library and i found many functions and things there but didnt find a function to do this.
But dont know, maybe i didnt see it.
I am a bit lost. I need some advices to do this.
I found "fnDrawCallback" and "fnPreDrawCallback" but still dont get it :(
Maybe i am wrong, but i didnt find datatables examples working with Json data ( from server side processing ) not being the default data ( sEcho, iTotalRecords, iTotalDisplayRecords, aaData, [aoColumns] ) like
var debug; ... "fnServerData": function ( sUrl, aoData, fnCallback, oSettings ) { oSettings.jqXHR = $.ajax( { "url": sUrl, "data": aoData, "success": function (json) { if ( json.sError ) { oSettings.oApi._fnLog( oSettings, 0, json.sError ); } $(oSettings.oInstance).trigger('xhr', [oSettings, json]); // MYCODE a simple example, i pass sTitle ( Columns titles ) on the json for (var property in json){ if ( property == "aoColumns"){ for (var aoColIndex in json["aoColumns"]){ oSettings["aoColumns"][aoColIndex]["sTitle"] = json["aoColumns"][aoColIndex]["sTitle"]; } } } //oSettings.oApi._fnAjaxUpdateDraw( oSettings, json); //oSettings.oApi._fnDraw( oSettings ); debug["oSettings"] = oSettings; // ENDMYCODE it works but datatable isnt drawed }, "dataType": "json", "cache": false, "type": oSettings.sServerMethod, "error": function (xhr, error, thrown) { if ( error == "parsererror" ) { oSettings.oApi._fnLog( oSettings, 0, "DataTables warning: JSON data from "+ "server could not be parsed. This is caused by a JSON formatting error." ); } } } ); }, ... console.log( debug );
I think i know how pass the json, with the new properties data, and change the datatable properties with the new one, but datatable isnt draw/printed/refreshed.
I follow the right steps ?
I will change this code for a function that allow me to parse data from json and store on datatable.oSettings.
for (var property in json){ if ( property == "aoColumns"){ for (var aoColIndex in json["aoColumns"]){ oSettings["aoColumns"][aoColIndex]["sTitle"] = json["aoColumns"][aoColIndex]["sTitle"]; } } }Maybe u can tell me if there is already a funtion to do this.
I checked JQuery.dataTables.js library and i found many functions and things there but didnt find a function to do this.
But dont know, maybe i didnt see it.
I am a bit lost. I need some advices to do this.
I found "fnDrawCallback" and "fnPreDrawCallback" but still dont get it :(