jquery中的表格控件。javascript
$mmGrid = $('#table-m1').mmGrid({ autoLoad: true, cols: cols, fullWidthRows: true, url: 'list_data.jhtml', params: function () { return $("#listForm").serializeObject(); }, plugins: [ $('#paginator').mmPaginator() ] });
cols是列的定義。html
var cols = [ { title: '${message("車牌號")}', name: 'car_number', align: 'center', renderer: function (val, item, rowIndex) { return '<a href="javascript:void(0);" onClick="edit(' + item.id + ')" class="red">' + val + '</a>'; } }, {title: '${message("車型")}', name: 'car_type', align: 'center'}, {title: '${message("機構名稱")}', name: 'sale_org_name', align: 'center'}, {title: '${message("備註")}', name: 'remark', align: 'center'}, ];
表格中的處理函數使用renderer:java
renderer: function (val, item, rowIndex) { return '<a href="javascript:void(0);" onClick="edit(' + item.id + ')" class="red">' + val + '</a>'; }
表格中的分頁插件使用:jquery
plugins: [$('#paginator').mmPaginator()]
須要在html中定義id爲paginator的div:函數
<div id="paginator"></div>
在後臺傳入的時候,定義一個變量繼承自Serializable,包含pageNumber和pageSize:this
public class Pageable implements Serializable { private static final long serialVersionUID = -3930180379790344299L; private static final int DEFAULT_PAGE_NUMBER = 1; private static final int DEFAULT_PAGE_SIZE = 100; private static final int MAX_PAGE_SIZE = 500; private int pageNumber; private int pageSize; public Pageable() { this.pageNumber = 1; this.pageSize = 100; } }