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 保持查詢條件(兩個(gè)頁面的hashCode相同時(shí)夭问,從一個(gè)跳轉(zhuǎn)到另一個(gè)頁面時(shí)會(huì)保持查詢條件)
<table class="table table-striped table-bordered table-hover" id="datatable_ajax">
<thead>
<以下被注釋的代碼 在列表頭部添加查詢條件的代碼 若是無查詢條件但是有如下的filter的代碼泽西,程序會(huì)報(bào)錯(cuò)>
<tr role="row" class="heading">
<th width="5%">序號(hào)</th>
<th width="20%">二級(jí)目的地名稱</th>
<th width="20%">排序</th>
<th width="20%">操作</th>
</tr>
</thead>
<tbody>
</tbody>
</table>