• 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

  • 相关阅读:
    考研打卡_Day04
    考研打卡_Day03
    考研打卡-Day02
    吾日三省-归隐
    为什么要写博客?
    用C语言写一个Helloworld_实现第一步编译运行
    C语言中的结构体是怎么定义的_怎么使用?
    C语言的常用的数据类型有哪些_所占字节分别是多少
    Vim编辑器中查找关键词命令_查找与替换命令_多窗口命令
    Vim的基本操作命令与光标移动命令
  • 原文地址:https://www.cnblogs.com/hailexuexi/p/14505484.html
Copyright © 2020-2023  润新知