tonytomov / jqGrid

jQuery grid plugin
www.trirand.com
2.84k stars 1.2k forks source link

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

Closed parallels999 closed 1 year ago

parallels999 commented 1 year ago

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 https://github.com/tonytomov/jqGrid/commit/209a08853373a55504db73cb0995a90d6b1984ab

The exception is on the lines https://github.com/tonytomov/jqGrid/blob/7ced5eee6b958b022c47e17c02dfa8a05e42bf40/js/grid.base.js#L6484-L6486 https://github.com/tonytomov/jqGrid/blob/7ced5eee6b958b022c47e17c02dfa8a05e42bf40/js/grid.base.js#L6524-L6526

Maybe solutions

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