我在尝试使用标题中所述的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'}
]
});
我该如何解决这个问题?任何帮助都会很棒,谢谢!
答案 0 :(得分:1)
您的问题非常简单:您将setGroupHeaders
方法的调用置于 jQuery(document).ready
块之外。因此,您在之前尝试创建分组标题将创建网格。所以你应该移动jQuery(document).ready
块内的最后一行。如果您希望更好地格式化代码,则会立即找到错误。