2 you are beautiful you_are_beautiful 于 2017.09.14 10:25 提问

jquery datatables插件 表格数据初始化时,数据加载两次

/** 表格的数据渲染 /
function drawTable(aa001, aa002, aa003) {
dataTable = $("#dataTable").DataTable({
"searching": false,
"ordering": false,
"destroy": true,
"lengthMenu": [ 10, 20, 25, 30 ],
"lengthChange": false,
"paging": true,
"ajax": {
"url":"
*",
"data": {"aa001": aa001, "aa002": aa002, "aa003": aa003}
},
"language": {
"emptyTable": "无相关数据!",
"info": "符合查询条件的数据共 TOTAL 条,当前第 STARTEND 条数据",
"infoEmpty": "当前显示0到0条,共0条记录",
"lengthMenu": "显示 MENU 条",
"loadingRecords": "加载中...",
"processing": "加载中...",
"zeroRecords": "未查询到相关数据!",
"paginate": {
"first": "首页",
"last": "尾页",
"next": "下一页",
"previous": "上一页"
}
},
"columns": [
{"class" : 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": "ab301"},

{ "data": "ab303"},
{ "data": "ac201"},
{ "data": "bm001"},
{ "data": "bm004"},
{ "data": "afk02"},
{ "data": "dc236"},
{ "data": "area"}
]
});
}

3个回答

you_are_beautiful
you_are_beautiful   2017.09.14 10:28

/** 表格的数据渲染 /
function drawTable(aa001, aa002, aa003) {
dataTable = $("#dataTable").DataTable({
"searching": false,
"ordering": false,
"destroy": true,
"lengthMenu": [ 10, 20, 25, 30 ],
"lengthChange": false,
"paging": true,
"ajax": {
"url":"*",
"data": {"aa001": aa001, "aa002": aa002, "aa003": aa003}
},
"language": {
"emptyTable": "无相关数据!",
"info": "符合查询条件的数据共 TOTAL 条,当前第 START 至 END 条数据",
"infoEmpty": "当前显示0到0条,共0条记录",
"lengthMenu": "显示 MENU 条",
"loadingRecords": "加载中...",
"processing": "加载中...",
"zeroRecords": "未查询到相关数据!",
"paginate": {
"first": "首页",
"last": "尾页",
"next": "下一页",
"previous": "上一页"
}
},
"columns": [
{"class" : 'details-control',
"orderable": false,
"data": null,
"defaultContent": ''
},
{ "data": function (data, type, full) {
********console.log(data);********
return data.ab301;
}},

        { "data": "ab303"},
        { "data": "ac201"},
        { "data": "bm001"},
        { "data": "bm004"},
        { "data": "afk02"},
        { "data": "dc236"},
        { "data": "area"}
    ]
});

}

you_are_beautiful
you_are_beautiful   2017.09.14 10:30

在console.log(data)时,控制台出现两遍加载的数据。是什么原因呢。

sunny_desmond
sunny_desmond   2017.09.14 17:03

drawTable(aa001, aa002, aa003) 这个方法 你调用了几次?

Csdn user default icon
上传中...
上传图片
插入图片