jQuery datatables refresh data not working -
i can use server side fill datatables , other working cant refresh data after clicking on reload_table
element.clear datatable work correctly draw not working.
jquery:
$('#reload_table').live('click',function(){ otable_topics.fnreloadajax(otable_topics.fnsettings()); otable_topics.fncleartable(); otable_topics.fndraw(); $.ajax({ url: "server_processing.php", success: function() { // if worked, ask datatable redraw table new data $("#showtopics").datatable().fndraw(); // if js function useful (like deleting row), call it: success(); }, error: function() { // display error (like server couldn't reached...), or @ least try log } }); }); otable_topics =$('#showtopics').datatable({ "blengthchange": false, "idisplaylength": 12, "bscrollcollapse": true, "bjqueryui": true, "bautowidth": false, "sajaxsource": "server_processing.php", "spaginationtype": "full_numbers", "bprocessing": true, "fndrawcallback": function(osettings) { clickrowhandler_topics(); if ( osettings.aidisplay.length == 0 ) { return; } var ntrs = $('tbody tr', osettings.ntable); var icolspan = ntrs[0].getelementsbytagname('td').length; var slastgroup = ""; ( var i=0 ; i<ntrs.length ; i++ ) { var idisplayindex = osettings._idisplaystart + i; var sgroup = osettings.aodata[ osettings.aidisplay[idisplayindex] ]._adata[0]; if ( sgroup != slastgroup ) { var ngroup = document.createelement( 'tr' ); var ncell = document.createelement( 'td' ); ncell.colspan = icolspan; ncell.classname = "group"; ncell.innerhtml = sgroup; ngroup.appendchild( ncell ); ntrs[i].parentnode.insertbefore( ngroup, ntrs[i] ); slastgroup = sgroup; } } }, "aocolumndefs": [ { "bvisible": false, "atargets": [ 0 ] } ], "aasortingfixed": [[ 0, 'asc' ]], "aasorting": [[ 1, 'asc' ]], "fnserverparams": function ( aodata ) { aodata.push( {"name": "id" , "value": "i.id" }, {"name": "subject" , "value": "i.subject" }, {"name": "date_time", "value": "i.date_time"} , {"name": "posted_by", "value": "u.username"} , {"name": "ctitle" , "value": "c.title"} , {"name": "etitle" , "value": "e.title"}, {"name": "istatus" , "value": "i.status"}, {"name": "join" , "value": "join categories c on i.category = c.id join status_topics e on i.status = e.id join users u on i.posted_by = c.id"}, {"name": "action" , "value": "topics" } )} });
i have been using fnreloadajax load new data , fnlengthchange change page length while @ it.
otable.fncleartable(0); otable.fnreloadajax('/' + mylocation + '/' + mycustomerid); otable.fnlengthchange(pagelength);
Comments
Post a Comment