html頁面代碼:html
<table id="bugListTable" style="height: 640px;"> <thead style="height: 31px"> <tr> <th data-options="field:'id',width:calColumnWidth(0.05)">工單編號</th> <th data-options="field:'status',width:calColumnWidth(0.05), formatter:function(value,row,index){ return $('#bugStatus .status_' + value).html(); }">處理類型</th> <th data-options="field:'bugFrom',width:calColumnWidth(0.06), formatter:function(value,row,index){ return '遊戲中GM功能'; }">工單來源</th> <th data-options="field:'title',width:calColumnWidth(0.05)">工單標題</th> <th data-options="field:'content',width:calColumnWidth(0.1)">工單內容</th> <th data-options="field:'pid',width:calColumnWidth(0.05)">平臺</th> <th data-options="field:'areaId',width:calColumnWidth(0.05)">遊戲區</th> <th data-options="field:'roleId',width:calColumnWidth(0.08)">角色ID</th> <th data-options="field:'userId',width:calColumnWidth(0.1)">帳號ID</th> <th data-options="field:'roleName',width:calColumnWidth(0.08)">角色暱稱</th> <th data-options="field:'vipLevel',width:calColumnWidth(0.05),formatter:function(value,row,index){ return 'VIP等級: ' + value; }">用戶類型</th> <th data-options="field:'questionType',width:calColumnWidth(0.05)">問題類型</th> <th data-options="field:'ownerName',width:calColumnWidth(0.05)">負責人</th> <th data-options="field:'lastOperatorName',width:calColumnWidth(0.05)">最後處理人</th> <th data-options="field:'addTime',width:calColumnWidth(0.12), formatter:function(value,row,index){ var time = new Date(); time.setTime(value); return time.bfFormatter(); }">建立時間</th> <th data-options="field:'operation',width:calColumnWidth(0.04), formatter:function(value,row,index){ return value; }">操做</th> </tr> </thead> <tbody> </tbody> </table>
html頁面調用js:url
commonServerPagination('#bugListTable', undefined, "${ctx}/pss/bug/search.do", { 'startTime':function(){ return $('#startTime').val(); }, 'endTime':function(){ return $('#endTime').val(); }, "conditionType":function(){ return $('#conditionType').val(); }, "condition":function(){ return $('#condition').val(); }, "worldId":function(){ return $('#worldId').val(); } });
js方法實現:code
function commonServerPagination(selector, filter, url, extraParams,paraObj){ paraObj = paraObj || {}; var lf = pagerFilter; if(filter != undefined){ lf = filter; } $(selector).datagrid({ pagination:true, pageSize:paraObj.pageSize||50, pageList:paraObj.pageList||[10,20,30,40,50,100,500,1000], singleSelect:true, striped:true, rownumbers:20, autoRowHeight:false, render:'frozen', nowrap:false, url:url, onBeforeLoad: function (param) { if(extraParams){ for(var key in extraParams){ if(key == 'editorField'){ continue; } if(typeof extraParams[key] == 'function'){ param[key] = extraParams[key](); }else{ param[key] = extraParams[key]; } } } }, onLoadSuccess: function(data){ // for(var i = 0; i < data.rows.length; i++){ // if(loadSuccessCallback){ // loadSuccessCallback(data.rows[i]); // $(selector).datagrid('refreshRow', i); // } // } }, onDblClickCell: function(index,field,value){ var hiddenEditingIndex = $(selector).parent().find('.hiddenEditingIndex').val(); if((hiddenEditingIndex && hiddenEditingIndex != index) || (extraParams && extraParams['editorField'] && extraParams.editorField.indexOf(field) == -1)){ return; } var editingIndex = $(selector).datagrid('beginEdit'); $(selector).datagrid('beginEdit', index); var ed = $(selector).datagrid('getEditor', {index:index,field:field}); if(ed){ $(ed.target).focus(); } } }); /* var p = $('#punishListTable').datagrid('getPager'); $(p).pagination({ pageSize: 10,//每頁顯示的記錄條數,默認爲10 pageList: [5,10,15],//能夠設置每頁記錄條數的列表 beforePageText: '第',//頁數文本框前顯示的漢字 afterPageText: '頁 共 {pages} 頁', displayMsg: '當前顯示 {from} - {to} 條記錄 共 {total} 條記錄', }); */ }