列重新排序与JQGrid配合使用,可排序:true。现在我已经对标题进行了分组,它已停止工作。如何使用分组标题使列重新排序工作。这是示例代码
<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]);
});
答案 0 :(得分:1)
很抱歉,但jqGrid的许多功能都有相应的限制。您不能将sortable: true
或columnsChooser与Header grouping一起使用(请参阅documentation)
答案 1 :(得分:0)
Hiya 演示 http://jsfiddle.net/yNw3C/620/
请看看代码是否正常工作:即设置组合正常以及排序。
希望这有帮助,如果我遗漏了任何东西,请告诉我!
<强>码强>
$(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]);
});
图片强>