EasyUI Forum
May 19, 2024, 10:26:28 AM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to remove the following error  (Read 6081 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« on: April 30, 2019, 05:54:52 AM »

Though this error does not cause any unexpected behavior or change in my application, it always appear on the console. So I am looking for ways to remove the error, but could not find the solution.

Code:
Uncaught TypeError: Cannot read property 'panel' of undefined
    at Object.getPager (easyui.min.js:1)
    at n.fn.init.$.fn.datagrid (easyui.min.js:1)
    at HTMLTableElement.<anonymous> (easyui.min.js:1)
    at Function.each (jquery.min.js:2)
    at n.fn.init.each (jquery.min.js:2)
    at Object.loaded (easyui.min.js:1)
    at n.fn.init.$.fn.datagrid (easyui.min.js:1)
    at easyui.min.js:1
    at Object.success (easyui.min.js:1)
    at i (jquery.min.js:2)

I hope you can solve the problem.

Thanks and regards,

Alfred
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #1 on: May 02, 2019, 12:36:00 AM »

When calling the 'getPager' method before creating the datagrid, the error occurs. Please make sure to initialize the datagrid component before calling this method.
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #2 on: May 11, 2019, 07:44:25 PM »

Please show an example.


Thanks
Alfred
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #3 on: May 13, 2019, 07:11:50 AM »

Look at this example:
Code:
<table id="dg" class="easyui-datagrid" data-options="pagination:true" title="Custom DataGrid Pager"></table>
<script type="text/javascript">
var pager = $('#dg').datagrid('getPager');
console.log(pager)
</script>

The 'getPager' method is called when the page is loaded. It will raise errors because it is called before creating the datagrid. To solve this issue, use this code instead.
Code:
<table id="dg" class="easyui-datagrid" data-options="pagination:true" title="Custom DataGrid Pager"></table>
<script type="text/javascript">
$(function(){
var pager = $('#dg').datagrid('getPager');
console.log(pager)
})
</script>
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #4 on: May 13, 2019, 07:22:55 AM »

Thanks for the reply. How do I do it in the combogrid? This is the one that causes the error.

Code:
<input name="feeinfo" id="ipBox" class="easyui-combogrid"
  data-options="panelWidth:800, mode:'remote', method:'get', pagination:true,
  idField:'id', textField:'name',  hasDownArrow:true, striped:true,
  prompt:'Type to search..',  url:'Data/list',
  columns: [[
    {field:'id',title:'<b>Id</b>', halign:'center', align:'center', width:40,sortable:true},
    {field:'name',title:'<b>Name</b>', halign:'center', align:'left', width:120,sortable:true},
  ]], fitColumns: true, panelHeight:250,
  onSelect:function(index, row) {
      showInfo(row.id);
      $('#ipBox').combogrid('clear');
  },
  panelEvents: $.extend({}, $.fn.combogrid.defaults.panelEvents, {
      mousedown: function(){}
  }),
  onHidePanel:function(index,row){
      $(this).combogrid('close');
      $('#ipBox').combogrid('clear');
  }, emptyMsg:'<span style=color:red>No Data...</span>'" style="width:100%; height:35px;">

I did try with the following but it does not work:

Code:
$(function(){
    $('#ipBox').combogrid({
        onBeforeLoad: function(param){
           var g = $('#ipBox').combogrid('grid');
           var pager = g.datagrid('getPager');
        }
      });
   });
« Last Edit: May 13, 2019, 07:36:31 AM by Alfred » Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #5 on: May 13, 2019, 06:53:07 PM »

This example is created from your code. No error occurs.
http://code.reloado.com/oluruy/edit#preview
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #6 on: May 13, 2019, 07:29:27 PM »

Thanks Jarry. But my combogrid is inside a dialog. The problem is still there.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #7 on: May 15, 2019, 06:46:05 PM »

You should put all the script code into the <body> to be loaded from the dialog.
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!