var userTableAjax = function () {
var grid;
var gridRecords = function (url) {
grid = new Datatable();
grid.init({
src: $("#datatable_ajax"),
hashCode:'',
onSuccess: function (grid) {
},
onError: function (grid) {
},
csrf:$("#_csrf").val(),
loadingMessage: '加载中...',
hashCode: "prod_list",
dataTable: {
"bInfo": true,
"bStateSave": false,
"bSort": false,
"lengthMenu": [
[10, 20, 50],
[10, 20, 50]
],
"pageLength": 10,
"ajax": {
"url": url,
},
"dom": '<<t>pli>',
}
});
};
return {
init: function (url) {
gridRecords(url);
},reflash:function(){//刷新
grid.submitFilter();
}
};
}();
userTableAjax.init($url);
userTableAjax.reflash(); 的使用
dataTables
hashCode 保持查询条件(两个页面的hashCode相同时,从一个跳转到另一个页面时会保持查询条件)
<table class="table table-striped table-bordered table-hover" id="datatable_ajax">
<thead>
<以下被注释的代码 在列表头部添加查询条件的代码 若是无查询条件但是有如下的filter的代码,程序会报错>
<tr role="row" class="heading">
<th width="5%">序号</th>
<th width="20%">二级目的地名称</th>
<th width="20%">排序</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>