0

尝试使用标题中所述的 goupHeader 时收到错误消息,因此 groupHeader 不起作用。我已按照 wiki 的所有说明进行操作。这是我的代码

<script type="text/javascript"> 
jQuery().ready(function (){
    jQuery("#t_dosen_gol").jqGrid({
        url:'{URL_XML}',
        datatype: "xml",
        sortable: false,
        colNames:['UNIT KERJA','III/a', 'III/b', 'III/c','III/d','IV/a','IV/b','IV/c','IV/d','IV/e','JUMLAH'],
        colModel:[
            {name:'satkerNama',index:'satkerNama', width:250},
            {name:'3a',index:'3a', width:50, align:"center", sortable:false, resizable: false},
            {name:'3b',index:'3b', width:50, align:"center", sortable:false, resizable: false},
            {name:'3c',index:'3c', width:50, align:"center", sortable:false, resizable: false},
            {name:'3d',index:'3d', width:50, align:"center", sortable:false, resizable: false},
            {name:'4a',index:'4a', width:50, align:"center", sortable:false, resizable: false},
            {name:'4b',index:'4b', width:50, align:"center", sortable:false, resizable: false},
            {name:'4c',index:'4c', width:50, align:"center", sortable:false, resizable: false},
            {name:'4d',index:'4d', width:50, align:"center", sortable:false, resizable: false},
            {name:'4e',index:'4e', width:50, align:"center", sortable:false, resizable: false},
            {name:'subtotal',index:'subtotal', width:75,align:"center"}                 
        ],
        //rowNum:10,
        width: 700,
        height: 400,
        //rowList:[10,20,30],
        pager: jQuery('#p_dosen_gol'),
        sortname: 'satkerid',
        viewrecords: true,
        sortorder: "desc",
        caption:"Tenaga Dosen Tetap Menurut Golongan/Ruang dan Unit Kerja"
    }).navGrid('#p_dosen_gol',{edit:false,add:false,del:false,search:false})});

jQuery("#t_dosen_gol").jqGrid('setGroupHeaders', { 
    useColSpanStyle: true, 
    groupHeaders:[ 
        {startColumnName: '3a', numberOfColumns: 9, titleText: 'GOLONGAN/RUANG'} 
    ] 
});

我该如何解决这个问题?任何帮助都会很棒,谢谢!

4

1 回答 1

1

您的问题很简单:您将setGroupHeaders方法调用置于 jQuery(document).ready块外。因此,您当前尝试在创建网格之前创建分组标题。因此,您必须将最后一行移到jQuery(document).ready块内。如果你能更好地格式化你的代码,这些错误将立即被发现。

于 2012-05-30T19:39:02.940 回答