1

我想显示多个标题行,这样我的顶部标题行组将跨越一组较低的标题行列名。我知道你可以在 jqGrid 中做到这一点。它的一个例子是:

jQuery("#samples").jqGrid('setGroupHeaders', { 
 useColSpanStyle: true, 
 groupHeaders:[ 
    {startColumnName: 'totalweight', numberOfColumns: 6, titleText: 'Count'}, 
    {startColumnName: 'bellyburst', numberOfColumns: 3, titleText: 'Damaged'}, 
    {startColumnName: 'a', numberOfColumns: 6, titleText: 'Weight'}, 
    {startColumnName: 'fish', numberOfColumns: 2, titleText: 'Quality'}, 
 ] 
});
4

2 回答 2

0

在 jqxGrid 中从未见过这样的功能。如果您的网格非常静态,您可以尝试手动添加该行,但这可能会成为一个麻烦的解决方案。如果您尝试这样做,请务必将您的 html 放在 jqxGrid div 之外,因为太多东西在该 div 内移动。他们为您的 html 蒙皮,因此它看起来像是网格的一部分。

另一种解决方案可能是使用副标题。您可以在定义列时将其归档。您可以添加一个渲染器,它是一个返回标头的函数。我没有尝试,但我很确定您可以在标题中返回 HTML,并构建字幕。

于 2014-01-10T15:28:13.280 回答
0

我想您可以使用 jQWidget JQX 网格中引入的列层次结构选项。请看下面的例子。

<!DOCTYPE html>
<html lang="en">
<head>
    <title id='Description'>This sample illustrates the Columns Hierarchy feature of jqxGrid.
    </title>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.11.1.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdata.js"></script> 
    <script type="text/javascript" src="../../jqwidgets/jqxbuttons.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxscrollbar.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxmenu.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.sort.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.filter.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsresize.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.columnsreorder.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.pager.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.edit.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxgrid.selection.js"></script> 
    <script type="text/javascript" src="../../jqwidgets/jqxpanel.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcheckbox.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxlistbox.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxdropdownlist.js"></script>
    <script type="text/javascript" src="../../scripts/demos.js"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            // prepare the data
            var source =
            {
                datatype: "xml",
                datafields: [
                     { name: 'SupplierName', type: 'string' },
                     { name: 'Quantity', type: 'number' },
                     { name: 'OrderDate', type: 'date' },
                     { name: 'OrderAddress', type: 'string' },
                     { name: 'Freight', type: 'number' },
                     { name: 'Price', type: 'number' },
                     { name: 'City', type: 'string' },
                     { name: 'ProductName', type: 'string' },
                     { name: 'Address', type: 'string' }
                ], 
                url: '../sampledata/orderdetailsextended.xml',
                root: 'DATA',
                record: 'ROW'
            };
            var dataAdapter = new $.jqx.dataAdapter(source, {
                loadComplete: function () {
                }
            });
            // create jqxgrid.
            $("#jqxgrid").jqxGrid(
            {
                width: 850,
                source: dataAdapter,
                pageable: true,
                autorowheight: true,
                altrows: true,
                columnsresize: true,
                columns: [
                  { text: 'Supplier Name', cellsalign: 'center', align: 'center', datafield: 'SupplierName', width: 110 },
                  { text: 'Name', columngroup: 'ProductDetails', cellsalign: 'center', align: 'center', datafield: 'ProductName', width: 120 },
                  { text: 'Quantity', columngroup: 'ProductDetails', datafield: 'Quantity', cellsformat: 'd', cellsalign: 'center', align: 'center', width: 80 },
                  { text: 'Freight', columngroup: 'OrderDetails', datafield: 'Freight', cellsformat: 'd', cellsalign: 'center', align: 'center', width: 100 },
                  { text: 'Order Date', columngroup: 'OrderDetails', cellsalign: 'center', align: 'center', cellsformat: 'd', datafield: 'OrderDate', width: 100 },
                  { text: 'Order Address', columngroup: 'OrderDetails', cellsalign: 'center', align: 'center', datafield: 'OrderAddress', width: 100 },
                  { text: 'Price', columngroup: 'ProductDetails', datafield: 'Price', cellsformat: 'c2', align: 'center', cellsalign: 'center', width: 70 },
                  { text: 'Address', columngroup: 'Location', cellsalign: 'center', align: 'center', datafield: 'Address', width: 120 },
                  { text: 'City', columngroup: 'Location', cellsalign: 'center', align: 'center', datafield: 'City', width: 80 }
                ],
                columngroups: 
                [
                  { text: 'Product Details', align: 'center', name: 'ProductDetails' },
                  { text: 'Order Details', parentgroup: 'ProductDetails', align: 'center', name: 'OrderDetails' },
                  { text: 'Location', align: 'center', name: 'Location' }
                ]
            });
        });
    </script>
</head>
<body class='default'>
    <div id="jqxgrid">
    </div>
</body>
</html>
于 2016-02-09T06:58:03.870 回答