zoukankan      html  css  js  c++  java
  • jgGrid pivot reload重新加载及刷新数据

    1.当使用jqGrid进行多维表时,reload方法会不停的重复增加标题的行数。

    解决办法:直接删除jqGrid,重新初始化页面。

    function query(){//crossTable pivot不能用新数据去reload,只能重新初始化和生成jqgrid
        $("#showReport div").remove();
        $("#showReport").append("<table id='jqGridList'></table>");
        $("#showReport").append("<div id='pager2'></div>");
        pageInit(newJson);
    }

    2.初始化方法

    function pageInit(jsonArray){
    $("#jqGridList").jqGrid('jqPivot', 
         jsonArray,//'<%=basePath%>js/data/data_copy.json',
          // pivot options
          {
            xDimension : [
              {
                dataName: 'group', 
                90
              },
              {
                dataName: 'name'
              }
            ],
            yDimension : [
              {
                dataName: 'country',
                130
              }
            ],
            aggregates : [
              { 
                member : 'amount', 
                aggregator : 'sum', 
                130,
                label:'合计汇总',
                formatter:'integer',
                align:'right',
                summaryType: 'sum'
              }
              ,{ 
                member : 'amount', 
                aggregator : 'count', 
                100,
                label:'Count',
                formatter:'integer',
                align:'right',
                summaryType: 'sum'
              }
              
            ],
            colTotals: true,
            rowTotals: true
          }, 
          // grid options
          {
             1000,
            rowNum : 10,
            pager: "#pager2",
            caption: "Rows grouping"
          });
    };


    3.数据:

    var newJson=[ {
            "CategoryName" : "Beverages",
            "ProductName" : "Steeleye Stout",
            "Country" : "UK",
            "Price" : "1008.0000",
            "Quantity" : "65"
        }, {
            "CategoryName" : "Beverages",
            "ProductName" : "Laughing Lumberjack Lager",
            "Country" : "USA",
            "Price" : "140.0000",
            "Quantity" : "10"
        }, {
            "CategoryName" : "Beverages",
            "ProductName" : "Lakkaliku00f6u00f6ri",
            "Country" : "USA",
            "Price" : "2160.0000",
            "Quantity" : "120"
        }, {
            "CategoryName" : "Beverages",
            "ProductName" : "Guaranu00e1 Fantu00e1stica",
            "Country" : "USA",
            "Price" : "436.5000",
            "Quantity" : "97"
        }, {
            "CategoryName" : "Beverages",
            "ProductName" : "Ipoh Coffee",
            "Country" : "UK",
            "Price" : "1656.0000",
            "Quantity" : "36"
        }];

    4.html

    <body>
    <table>
    <tr>
            <td id="showReport" colspan="2">
                <table id="jqGridList"></table> 
                <div id="pager2"></div>
            </td>
        </tr>
       </table>
      </body>

    5.页面效果

  • 相关阅读:
    ssh2整合velocity出现Unable to find resource
    struts2之PreResultListener(转)
    Struts2源码浅析-请求处理(转)
    大型WEB网站架构深入分析
    大型网站技术架构探讨
    网易大型应用架构与实践
    二叉树及各种二叉树的应用
    centOS上安装MySQL5.7
    Caused by: java.lang.NoClassDefFoundError: Could not initialize class org.elasticsearch.threadpool.ThreadPool
    elasticsearch的插件安装
  • 原文地址:https://www.cnblogs.com/pu20065226/p/9808800.html
Copyright © 2011-2022 走看看