tonytomov / jqGrid

jQuery grid plugin

Home Page:www.trirand.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TypeError: Cannot read properties of undefined (reading 'length')

parallels999 opened this issue · comments

I'm trying 5.8 release and i'm getting the exception because $t.p.colSpanHeader is undefined:

jQuery.Deferred exception: Cannot read properties of undefined (reading 'length') 
TypeError: Cannot read properties of undefined (reading 'length')
    at HTMLTableElement.<anonymous> (http://localhost:82/assets/jqGrid/js/grid.base.js?x=2:6524:26)
    at Function.each (http://localhost:82/assets/jquery/jquery.min.js:2:3003)
    at S.fn.init.each (http://localhost:82/assets/jquery/jquery.min.js:2:1481)
    at S.fn.init.showHideCol (http://localhost:82/assets/jqGrid/js/grid.base.js?x=2:6467:15)
    at $.fn.jqGrid (http://localhost:82/assets/jqGrid/js/grid.base.js?x=2:2123:13)
    at HTMLTableElement.<anonymous> (http://localhost:82/assets/jqGrid/js/grid.base.js?x=2:6533:39)
    at Function.each (http://localhost:82/assets/jquery/jquery.min.js:2:3003)
    at S.fn.init.each (http://localhost:82/assets/jquery/jquery.min.js:2:1481)
    at S.fn.init.hideCol (http://localhost:82/assets/jqGrid/js/grid.base.js?x=2:6533:15)
    at $.fn.jqGrid (http://localhost:82/assets/jqGrid/js/grid.base.js?x=2:2123:13) undefined

It seems related from this commit 209a088

The exception is on the lines

jqGrid/js/grid.base.js

Lines 6484 to 6486 in 7ced5ee

if($t.p.colSpanHeader.length) {
$($t).jqGrid('destroyColSpanHeader', false);
}

jqGrid/js/grid.base.js

Lines 6524 to 6526 in 7ced5ee

if($t.p.colSpanHeader.length) {
$($t).jqGrid('setColSpanHeader', $t.p.colSpanHeader);
}

Maybe solutions

if(($t.p.colSpanHeader||[]).length) { 
// Or
if($t.p.colSpanHeader?.length) { 
// Or better, adds an empty array as defauly value
colSpanHeader: [],