参考地址:http://www.trirand.com/jqgridwiki/doku.php?id=wiki:groupingheadar
Grouping of the header should be used after the grid is created. For this purpose we have created a method which is called setGroupHeaders.
One typical implementation can look like this
$(document).ready(function(){ jQuery("#gridTable").jqGrid({ colNames: [‘Date‘, ‘Client‘, ‘Amount‘, ‘Tax‘, ‘Total‘, ‘Closed‘, ‘Shipped via‘, ‘Notes‘], colModel: [ {name: ‘invdate‘, index: ‘invdate‘, width: 80, align: ‘center‘, sorttype: ‘date‘, formatter: ‘date‘, formatoptions: {newformat: ‘d-M-Y‘}, datefmt: ‘d-M-Y‘}, {name: ‘name‘, index: ‘name‘, width: 70 }, {name: ‘amount‘, index: ‘amount‘, width: 75, formatter: ‘number‘, sorttype: ‘number‘, align: ‘right‘}, {name: ‘tax‘, index: ‘tax‘, width: 75, formatter: ‘number‘, sorttype: ‘number‘, align: ‘right‘}, {name: ‘total‘, index: ‘total‘, width: 75, formatter: ‘number‘, sorttype: ‘number‘, align: ‘right‘}, {name: ‘closed‘, index: ‘closed‘, width: 75, align: ‘center‘, formatter: ‘checkbox‘, edittype: ‘checkbox‘, editoptions: {value: ‘Yes:No‘, defaultValue: ‘Yes‘}}, {name: ‘ship_via‘, index: ‘ship_via‘, width: 100, align: ‘center‘, formatter: ‘select‘, edittype: ‘select‘, editoptions: {value: ‘FE:FedEx;TN:TNT;IN:Intim‘, defaultValue: ‘Intime‘}}, {name: ‘note‘, index: ‘note‘, width: 70, sortable: false} ], rowNum: 10, rowList: [5, 10, 20], }); jQuery("#gridTable").jqGrid(‘setGroupHeaders‘, { useColSpanStyle: false, groupHeaders:[ {startColumnName: ‘amount‘, numberOfColumns: 3, titleText: ‘<em>Price</em>‘}, {startColumnName: ‘closed‘, numberOfColumns: 2, titleText: ‘Shiping‘} ] }); jQuery("#gridTable").jqGrid(‘setGroupHeaders‘, { useColSpanStyle: false, groupHeaders:[ {startColumnName: ‘amount‘, numberOfColumns: 2, titleText: ‘<em>Price22</em>‘}, {startColumnName: ‘total‘, numberOfColumns: 1, titleText: ‘Shiping2‘}, {startColumnName: ‘closed‘, numberOfColumns: 2, titleText: ‘Shiping‘} ] }); });
时间: 2024-10-29 15:54:53