diff --git a/desktop/js/view_edit.js b/desktop/js/view_edit.js index dd5cf98b7c..de28f32dc2 100644 --- a/desktop/js/view_edit.js +++ b/desktop/js/view_edit.js @@ -598,11 +598,15 @@ document.getElementById('div_pageContainer').addEventListener('click', function( } if (_target = event.target.closest('#div_viewZones .bt_addViewTable')) { - var table = _target.closest('.viewZone').querySelector('table.div_viewData') + let table = _target.closest('.viewZone').querySelector('table.div_viewData') if (_target.getAttribute('data-type') == 'line') { - var line = '' + let line = '' line += '' - for (var i = 0; i < table.tBodies[0].children[0].children.length - 1; i++) { + let length = 1; + if(table.tBodies[0].children){ + length = table.tBodies[0].children[0].children.length - 1 + } + for (let i = 0; i < length; i++) { line += '' line += '
' line += '' @@ -614,11 +618,11 @@ document.getElementById('div_pageContainer').addEventListener('click', function( } line += '' table.tBodies[0].insertAdjacentHTML('beforeend', line) - - } else if (_target.getAttribute('data-type') == 'col') { + } + if (_target.getAttribute('data-type') == 'col') { table.tHead.childNodes[0].insertAdjacentHTML('beforeend', '') table.tBodies[0].childNodes.forEach(_tr => { - var col = '' + let col = '' col += '
' col += '' col += ''