Reputation: 2844
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]);
});
Upvotes: 1
Views: 2702
Reputation: 34107
Hiya demo http://jsfiddle.net/yNw3C/620/
Please take a look the code does work as it should: i.e. set group happened fine and the sorting as well.
Hope this helps and let me know if I missed anything!
code
$(document).ready(function() {
drawGrid();
jQuery("#grid").jqGrid('setGroupHeaders', {
useColSpanStyle: false,
groupHeaders: [
{
startColumnName: 'amount',
numberOfColumns: 2,
titleText: '<em>Financial</em>'},
]
});
for (var i = 0; i <= mydata.length; i++)
jQuery("#grid").jqGrid('addRowData', i + 1, mydata[i]);
});
Image
Upvotes: 0
Reputation: 221997
Sorry, but many features of jqGrid has the corresponding limitations. You can't use sortable: true
or columnsChooser together with Header grouping (see documentation)
Upvotes: 1