jquery databtable editable 怎么切换ajax Source

2024-11-07 13:52:02
推荐回答(1个)
回答1:

"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "table", "value": "wordforms" } );
$.ajax( {
"dataType": 'json',
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}

"fnServerData": function ( sSource, aoData, fnCallback ) {
/* Add some extra data to the sender */
aoData.push( { "name": "more_data", "value": "my_value" } );
$.getJSON( sSource, aoData, function (json) {
/* Do whatever additional processing you want on the callback, then tell DataTables */
fnCallback(json)
} );
}

ReloadAjax, same source URL, different POST parameters
对于仅使用jq.datatable version >1.8.2 及jq.jeditable ,可以使用fnReloadAjax(url?param=newValue)
对于使用jq.datatable.editable的,因为这个插件是用的jq.datatable version 1.7.5,所以有许多新版功能还没有实现。所以要实现更改ajax source的参数,就需要用到
"fnServerData": function ( sSource, aoData, fnCallback ) {
aoData.push( { "name": "table", "value": param } );
$.ajax( {
"dataType": 'json',
"url": sSource,
"data": aoData,
"success": fnCallback
} );
}
在外部的button或者select里更改param的值后调用oTable.fnDraw();
在服务器端要得到参数,只需要getParam("table"); 参数名字就是在aoData里name的值。