EasyUI Forum
May 15, 2024, 01:02:22 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: treegrid - cannot read property <fieldname> of null [solved]  (Read 7656 times)
devnull
Sr. Member
****
Posts: 431


View Profile
« on: October 26, 2017, 05:42:45 AM »

version is 1.44.

I have a treegrid, that has just a few columns, the data loads fine, but when I click on a leaf row, I get the easyui error:

jquery.easyui.min.js:8881 Uncaught TypeError: Cannot read property 'text' of null
jquery.easyui.min.js:8881 Uncaught TypeError: Cannot read property 'revn' of null
jquery.easyui.min.js:8881 Uncaught TypeError: Cannot read property 'desc' of null

depending on whether I click the text, revn or desc cell, actually I am not interested in cell edit, all I want to do is select the row, but easyui is stopping me:

Code:
else {
            var row = opts.finder.getRow(_63e, _63f);
            var td = tt.closest("td[field]", tr);
            if (td.length) {
                var _642 = td.attr("field");
                opts.onClickCell.call(_63e, _63f, _642, row[_642]);
            }

It is failing on this line: opts.onClickCell.call(_63e, _63f, _642, row[_642]);




« Last Edit: October 26, 2017, 04:09:15 PM by devnull » Logged

-- Licensed User --
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #1 on: October 26, 2017, 06:14:05 AM »

It seems that the row does not have an id, but why would that be ?

Code:
<tr id="datagrid-row-r7-2-undefined" node-id="undefined" class="datagrid-row"><td field="text"><div style="height:auto;" class="datagrid-cell datagrid-cell-c7-text"><span class="tree-indent"></span><span class="tree-indent"></span><span class="tree-indent"></span><span class="tree-indent"></span><span class="tree-icon tree-file icon-jpg"></span><span class="tree-title">TS_P1</span></div></td><td field="revn"><div style="height:auto;" class="datagrid-cell datagrid-cell-c7-revn">A1</div></td><td field="desc"><div style="height:auto;" class="datagrid-cell datagrid-cell-c7-desc">test tt</div></td></tr>
Logged

-- Licensed User --
jarry
Administrator
Hero Member
*****
Posts: 2264


View Profile Email
« Reply #2 on: October 26, 2017, 07:00:45 AM »

The idField and treeField properties must be set.
Logged
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #3 on: October 26, 2017, 04:03:10 PM »

They are set:

Code:
        $('#folds').treegrid({
          lines: false,
          fit: true,
          method: 'get',
          idField: 'treeid',
          treeField: 'text',
          fitComumns: true,
          init: false,
          url:'/?_sqlid=admin^dir_tree&_func=get&appid=grp&async=yes',
        
          columns:[[
            {field:'id',hidden:true},
            {field:'text',title:'Folder',width:150,fixed:true},
            {field:'treeid',hidden:true},
            {field:'revn',width:40,fixed:true,title:'Rev',formatter:dwap.page.fmt},
            {field:'desc',title:'Description',formatter:dwap.page.fmt,width:200,fixed:false}
          ]],
})

The leaf rows that are showing this problem are loaded async.
Logged

-- Licensed User --
devnull
Sr. Member
****
Posts: 431


View Profile
« Reply #4 on: October 26, 2017, 04:09:02 PM »

OK, I have solved this, there was no problem with the initial load of the folders, the problem was with the leafs which were loaded asyncly.

So I discovered that the leaf loading did not include the idField, hence the missing id.
Logged

-- Licensed User --
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!