1, the core of the static page method
// distal tab - loadFilter datagrid property settings for this method name to function partPurchasePagerFilter (Data) { IF ( typeof data.length == 'Number' && typeof data.splice == 'function' ) { Data = { Total: data.length, rows: Data } } var DG = $ ( the this ); var the opts = dg.datagrid ( 'Options' ); var pager = dg.datagrid ( 'getPager' ); pager.pagination ({ onSelectPage: function (pageNum, the pageSize) { opts.pageNumber= pageNum; opts.pageSize = pageSize; pager.pagination('refresh', { pageNumber : pageNum, pageSize : pageSize }); dg.datagrid('loadData', data); } }); if (!data.originalRows) { data.originalRows = (data.rows); } var start = (opts.pageNumber - 1) * parseInt(opts.pageSize); var end = start + parseInt(opts.pageSize); if(opts.queryParams.searchText && opts.queryParams.likeFields) {// 实现前端查询过滤 var sTxt = opts.queryParams.searchText, fields = opts.queryParams.likeFields; var nRows = data.originalRows.filter(function(row){ var isMatch = false; fields.split(',').map(function(field) { if (sTxt && row[field] && row[field].indexOf(sTxt.trim()) < 0) { } else if(row[field]){ isMatch = true } }); return isMatch; }); data.total = nRows.length; data.rows = (nRows.slice(start, end)); }else { data.rows = (data.originalRows.slice(start, end)); } return data; }
2, front-end query filtering trigger
/ * * * Distal embodiment a lookup table * @param tb (object): table object * @param fields (string): matching field attribute (s separated by commas) * @param text (String): text retrieval
* @ eg: searchFun ($ ( '# userTable'), 'name, sex', ' Zhaogong Zi'); * * / function searchFun (TB, Fields, text) { // pass query parameters $ .extend (tb.datagrid ( 'Options' ) .queryParams, {searchText: text, likeFields: Fields}); // trigger table data refresh distal tb.parents ( 'DataGrid-wrap.') Find ( 'the pagination-Load.'. ) .click () ; }
Thus complete front tab considered complete <(* ¯ ▽ ¯ *) /