主要用动态加载表格中的数据使用.
var t = $('#ajaxtable_em').DataTable({
"bDestroy":true, //关键这句
....
加上他可以动态的加载内容,每次调用这个函数都会重新加载新的内容
function getstockdatafile(filename,did,errtext)
{
if ($.fn.DataTable.isDataTable( '#ajaxtable_em' )) {
//$('#ajaxtable_em').dataTable({"bDestroy":true}).fnClearTable();
}
var t = $('#ajaxtable_em').DataTable({
"bDestroy":true,
"dom": '<"toolbar">frtip',
ajax: "../../Runtime/Temp/"+filename+".txt",
columns: [
{ "data": "id"},
{ "data": "model" ,
"render": function ( data, type, full, meta ) {
return data+'<input type="hidden" name="stock['+full.id+'][model]" value="'+data+'" /> ';
}
},
{ "data": "sn" ,
"render": function ( data, type, full, meta ) {
return data+'<input type="hidden" name="stock['+full.id+'][sn]" value="'+data+'" /> ';
}
},
{ "data": "property" ,
"render": function ( data, type, full, meta ) {
return data+'<input type="hidden" name="stock['+full.id+'][property]" value="'+data+'" /> '+'<input type="hidden" name="stock['+full.id+'][ban]" value="'+full.ban+'" /> ';
}
},
{ "data": "message"}
],
select: true,
"order": [[ 0, "desc" ]],
//"scrollY": "400px",
// "scrollCollapse": true,
// "paging": false,
"pagingType": "full_numbers",
//自动保存状态
stateSave: false,
iDisplayLength :1000,
"oLanguage": {
"sLengthMenu": "每页显示 _MENU_ 条记录",
"sZeroRecords": "对不起,查询不到任何相关数据",
"sInfo": "当前显示 _START_ 到 _END_ 条,共 _TOTAL_ 条记录",
"sInfoEmtpy": "找不到相关数据",
"sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
"sProcessing": "正在加载中...",
"sSearch": "搜索",
"sUrl": "", //多语言配置文件,可将oLanguage的设置放在一个txt文件中,例:Javascript/datatable/dtCH.txt
"oPaginate": {
"sFirst": "第一页",
"sPrevious": " 上一页 ",
"sNext": " 下一页 ",
"sLast": " 最后一页 "
}
} //多语言配置
});
$("#ajaxtable_em_wrapper .toolbar").html('<b class="quickb">{$objdoc.name|msubstr=0,36} : '+errtext+'</b>');