zoukankan      html  css  js  c++  java
  • easyui datagrid(‘getPager’)为空问题 Cannot read property 'panel' of undefined

    <table id='grid' class='easyui-datagrid' style='100%;height:450px' 
                title='列表' iconCls='icon-table' pagination='true' rownumbers='true' fitColumns='true' singleSelect='true'  striped='true'  >  
            <thead>  
                <tr>  
                     
                    <th field='id' width='10' hidden='true'>编号</th>      
                    <th field='name' width='20'align='center'>姓名</th>   
     
                    <th field='created_user_name' width='20' align='center'>创建人</th> 
                    <th field='date_entered' width='40' align='center'>创建时间</th>  
                    <th field='description' width='50' align='center'  hidden='true' >备注</th>  
                </tr>  
            </thead>  
    </table> 

    使用下面语句发现竟然提示为空,然后看了下源码,竟然没有id="grid"元素,可是我明明给table定义了id="grid" class="easyui-datagrid"让easyui自动加载为datagrid,已是感觉可能是自动识别的问题,就把class="easyui-datagrid"给删了,然后在js里面定义。

    var pg = $("#grid").datagrid("getPager");

    解决方法:

    加上这句: $( '#grid' ).datagrid();

        //分页事件
        $( '#grid' ).datagrid();  //加这句即可
        var pg = $("#grid").datagrid("getPager");
        if(pg)
        {
          $(pg).pagination({
             onBeforeRefresh:function(){
                console.log('before refresh');
                 },
                  onRefresh:function(pageNumber,pageSize){
                console.log(pageNumber);
                console.log(pageSize);
                  },
                  onChangePageSize:function(){
                console.log('pagesize changed');
              },
              onSelectPage:function(pageNumber,pageSize){
                  console.log(pageNumber);
                  console.log(pageSize);
              }
          });
        }

    竟然神奇的可以了。感谢原文作者的分享。

    原文链接:https://blog.csdn.net/u012925172/article/details/84749663

  • 相关阅读:
    Git使用笔记
    javascript获取表单值的7种方式
    javascript里阻止事件冒泡
    PHP面向对象04_串行化
    MySQL数据库锁定机制
    SAP R3和JAVA交换数据之JCO
    @XStreamAlias使用
    JCO 自定义DestinationDataProvider
    IBM websphere MQ 消息发送与获取
    WebSphere MQ 入门指南
  • 原文地址:https://www.cnblogs.com/hailexuexi/p/14505484.html
Copyright © 2011-2022 走看看