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

  • 相关阅读:
    小a和uim之大逃离(dp)
    c++stl应用入门
    tar: 从成员名中删除开头的“/”
    yii中rights安装
    python中operator.itemgetter
    python中时间和时区
    python --那些你应该知道的知识点
    rsync拉取远程文件
    django中时区设置
    django中添加用户
  • 原文地址:https://www.cnblogs.com/hailexuexi/p/14505484.html
Copyright © 2011-2022 走看看