47jqGrid 分组 - 分组表头行配置

简介: 47jqGrid 分组 - 分组表头行配置

这个例子展示了我们可以改变分组表头的行。这个可以结合groupText选项来实现。

其实有这两个模板:{0}这个的意思是分组的文本,{1}这个是在这个分组中有多少项。

例子:

HTML代码举例

<html>
  <head>
    <title>jqGrid 实例</title>
  </head>
  <body>
    ···代码省略···
    <table id="list483"></table> 
    <div id="plist483"></div>
    ···代码省略···
  </body>
</html>

javascript代码举例

$(function(){
  pageInit();
});
function pageInit(){
  var mydata = [
            {id:"1",invdate:"2010-05-24",name:"test",note:"note",tax:"10.00",total:"2111.00"} ,
            {id:"2",invdate:"2010-05-25",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
            {id:"3",invdate:"2007-09-01",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
            {id:"4",invdate:"2007-10-04",name:"test",note:"note",tax:"10.00",total:"210.00"},
            {id:"5",invdate:"2007-10-05",name:"test2",note:"note2",tax:"20.00",total:"320.00"},
            {id:"6",invdate:"2007-09-06",name:"test3",note:"note3",tax:"30.00",total:"430.00"},
            {id:"7",invdate:"2007-10-04",name:"test",note:"note",tax:"10.00",total:"210.00"},
            {id:"8",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"21.00",total:"320.00"},
            {id:"9",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
            {id:"11",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
            {id:"12",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
            {id:"13",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
            {id:"14",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
            {id:"15",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
            {id:"16",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
            {id:"17",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
            {id:"18",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
            {id:"19",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
            {id:"21",invdate:"2007-10-01",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
            {id:"22",invdate:"2007-10-02",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
            {id:"23",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
            {id:"24",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
            {id:"25",invdate:"2007-10-05",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
            {id:"26",invdate:"2007-09-06",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"},
            {id:"27",invdate:"2007-10-04",name:"test",note:"note",amount:"200.00",tax:"10.00",total:"210.00"},
            {id:"28",invdate:"2007-10-03",name:"test2",note:"note2",amount:"300.00",tax:"20.00",total:"320.00"},
            {id:"29",invdate:"2007-09-01",name:"test3",note:"note3",amount:"400.00",tax:"30.00",total:"430.00"}
          ];
        jQuery("#list483").jqGrid({
          data: mydata,
          datatype: "local",
          height: 'auto',
          rowNum: 30,
          rowList: [10,20,30],
             colNames:['Inv No','Date', 'Client', 'Amount','Tax','Total','Notes'],
             colModel:[
               {name:'id',index:'id', width:60, sorttype:"int"},
               {name:'invdate',index:'invdate', width:90, sorttype:"date", formatter:"date"},
               {name:'name',index:'name', width:100, editable:true},
               {name:'amount',index:'amount', width:80, align:"right",sorttype:"float", formatter:"number", editable:true},
               {name:'tax',index:'tax', width:80, align:"right",sorttype:"float", editable:true},    
               {name:'total',index:'total', width:80,align:"right",sorttype:"float"},    
               {name:'note',index:'note', width:150, sortable:false}    
             ],
             pager: "#plist483",
             viewrecords: true,
             sortname: 'name',
             grouping:true,
             groupingView : {
               groupField : ['name'],
               groupColumnShow : [false],
               groupText : ['<b>{0} - {1} Item(s)</b>']
             },
             caption: "Configure group header row"
        });
}
目录
相关文章
|
JavaScript 前端开发 Java
51jqGrid 分组 - 远程数据(排序过)
51jqGrid 分组 - 远程数据(排序过)
47 0
51jqGrid 分组 - 远程数据(排序过)
|
JavaScript 前端开发
49jqGrid 分组 - 分组行折叠
49jqGrid 分组 - 分组行折叠
57 0
|
JSON JavaScript 前端开发
78jqGrid - 列分组
78jqGrid - 列分组
45 0
|
JSON JavaScript 前端开发
76jqGrid - 分组行
76jqGrid - 分组行
37 0
|
JavaScript 前端开发 Java
57jqGrid 分组 - 多分组在头部显示求和(新)
57jqGrid 分组 - 多分组在头部显示求和(新)
40 0
|
JavaScript 前端开发 Java
72jqGrid 分组表头 - 有合并列的样式
72jqGrid 分组表头 - 有合并列的样式
62 0
|
JavaScript 前端开发 Java
52jqGrid 分组 - 远程数据(grandtotals排序)
52jqGrid 分组 - 远程数据(grandtotals排序)
53 0
|
JSON JavaScript 前端开发
77jqGrid - 带有汇总页脚的分组
77jqGrid - 带有汇总页脚的分组
43 0
|
JavaScript 前端开发
45jqGrid 分组 - 数组数据的简单分组
45jqGrid 分组 - 数组数据的简单分组
47 0
|
JavaScript 前端开发
46jqGrid 分组 - 隐藏分组列
46jqGrid 分组 - 隐藏分组列
49 0