我可以使用服务器端来填充数据表和其他工作,但单击reload_table
element.clear 数据表后我无法刷新数据。清除数据表工作正常,但绘制不工作。
查询:
$('#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 it worked, ask datatable to redraw the table with the new data
$("#showTopics").dataTable().fnDraw();
// if this js function does anything useful (like deleting the row), then call it:
Success();
},
error: function() {
// display any error (like server couldn't be reached...), or at least try to log it
}
});
});
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 = "";
for ( 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" }
)}
});