Sarath Sarath - 2 months ago 11
jQuery Question

JqGrid Column Reorder not working with grouped header

Column reordering works great with JQGrid with sortable: true. Now that I have grouped the header it has stopped working. How can I get the column reordering work with the grouped header. Here is the sample code

<script>
var mydata = [
{ id: "1", invdate: "2007-10-01", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" },
{ id: "2", invdate: "2007-10-02", name: "test2", note: "note2", amount: "300.00", tax: "20.00", total: "320.00" },
{ id: "3", invdate: "2007-09-01", name: "test3", note: "note3", amount: "400.00", tax: "30.00", total: "430.00" },
{ id: "4", invdate: "2007-10-04", name: "test", note: "note", amount: "200.00", tax: "10.00", total: "210.00" }

];
function drawGrid() {
jQuery("#list4").jqGrid({
sortable: true,
datatype: "local",
colNames: ['Inv No', 'Date', 'Client', 'Amount', 'Tax', 'Total', 'Notes'],
colModel: [
{ name: 'id', index: 'id', width: 55 },
{ name: 'invdate', index: 'invdate', width: 90 },
{ name: 'name', index: 'name asc, invdate', width: 100 },
{ name: 'amount', index: 'amount', width: 80, align: "right" },
{ name: 'tax', index: 'tax', width: 80, align: "right" },
{ name: 'total', index: 'total', width: 80, align: "right" },
{ name: 'note', index: 'note', width: 150, sortable: false }
],

sortname: 'invdate',
viewrecords: true,
sortorder: "desc",
caption: "Column Reordering Example"

});
}
$(document).ready(function () {
drawGrid();
jQuery("#list4").jqGrid('setGroupHeaders', {
useColSpanStyle: false,
groupHeaders: [
{ startColumnName: 'amount', numberOfColumns: 2, titleText: '<em>Financial</em>' },
]
});
for (var i = 0; i <= mydata.length; i++)
jQuery("#list4").jqGrid('addRowData', i + 1, mydata[i]);

});



Answer Source

Sorry, but many features of jqGrid has the corresponding limitations. You can't use sortable: true or columnsChooser together with Header grouping (see documentation)