How refresh the json data?
How refresh the json data?
harl123
Posts: 1Questions: 1Answers: 0
var json = Select_WasteWaterMP();
var table = $('#tb_WMP').DataTable({
"data":json,
"columns": [
{ "data": "MPCode", "title": "监测点编码" },
{ "data": "MPName", "title": "监测店名称" },
{ "data": "Longitude", "title": "经度" },
{ "data": "Latitude", "title": "纬度" },
{ "data": "Status", "title": "是否监测" },
{ "data": "IsMonitored", "title": "状态" }
],
"language": {
"url": '../../../js/plugins/DataTables/cn.txt'
},
"bPaginate": false, //是否显示分页
"bLengthChange": false, //每页显示的记录数
"bFilter": false, //搜索栏
"bSort": false, //是否支持排序功能
"bInfo": false, //显示表格信息
"columnDefs": [
{
"targets": [0],
"visible": false
}]
});
I bind data like this ....
Now I need reload the table ...and the json will be change..How could I do? I try ajax reload and no used..
This discussion has been closed.
Answers
You aren't using the DataTables
ajax
option, so DataTables knows nothing about your Ajax data source and thus theajax.reload()
method won't help at all.You need to use
clear()
androws.add()
to first clear the table and then add the new rows (which you would get using whatever Ajax control you are currently using to get the data).Allan