如何在Ajax中重新初始化数据表 [英] How To Reinitialize Datatable in Ajax
本文介绍了如何在Ajax中重新初始化数据表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要
*当加载Ajax时,将重新设置datable.
*When Ajax is loaded datable is reintailized.
-
我会逐步解释
i would explain in steps
- 这是第一步的输出: http://postimg.org/image/c6p8jwp3b/.
- 这是第二步的输出: http://postimg.org/image/6fm1z253h/
- 这是第三步的输出: http://postimg.org/image/5btny60xf/.
- Here is the output of first step :http://postimg.org/image/c6p8jwp3b/.
- Here is the output of second step :http://postimg.org/image/6fm1z253h/
- Here is the output of third step:http://postimg.org/image/5btny60xf/.
不重新初始化数据表.
No Reinitialize Of datatable.
我只想重新分配分页和搜索.
I just want paging and search should be reintialized.
我从以下网址获得了帮助: http://datatables.net/forums/discussion/256/fnreloadajax/p1 .
i have taken help from this url: http://datatables.net/forums/discussion/256/fnreloadajax/p1.
Ajax呼叫代码:
if ($('#teamTable').size() > 0)
{
$('#teamTable').dataTable({
"sPaginationType": "bootstrap"
});
}
$("#save_team").click(function() {
$.ajax({
type: "POST",
url: "asana_team.php",
data: { people_name: $('#e2').val(), team_name:$('#teamname').val() },
beforeSend : function(){
$("#team_table").remove();
$("#team_table_div").append("<center id=\"loading\" style=\"margin-top:25%;margin-bottom:25%\"><img src='../common/images/ajax-loader.gif' /></center>");
},
contentType: "application/x-www-form-urlencoded"
}).done(function(data) {
$("#loading").remove();
$('#team_table_div').append(data);
$('#teamTable').dataTable({
"sPaginationType": "bootstrap"
});
});
});
*工作正常,但我重新初始化了数据表中的分页,但未加载任何数据.
* working fine but i reintializing pagination in datatable no datable is loaded.
-
我已使用此代码重新整理表.
i have used this code to reinitailize table.
function callBack()
{
var call= $('#teamTable');
call.dataTable({
"sPaginationType": "bootstrap",
"sDom": "<'row-fluid'<'span6'l><'span6'f>r>t<'row-fluid'<'span6'i><'span6'p>>",
"oLanguage": {
"sLengthMenu": "_MENU_ records per page"
} });
}
$(document).ready(function() {
callBack();
});
推荐答案
首先使用
$('#teamTable').dataTable().fnDestroy();
然后重新零售
$('#teamTable').dataTable();
这篇关于如何在Ajax中重新初始化数据表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文