Open mrday86 opened 12 months ago
Short description getRecordHTML should return an array but it doesn't
What is current behavior sometimes it return empty string but the result it's used as an array anyway.
getRecordHTML(ind, lineNum, summary) { let tmph = '' let rec_html1 = '' let rec_html2 = '' let sel = this.last.selection let record // first record needs for resize purposes if (ind == -1) { rec_html1 += '<tr line="0">' rec_html2 += '<tr line="0">' if (this.show.lineNumbers) rec_html1 += '<td class="w2ui-col-number" style="height: 0px"></td>' if (this.show.selectColumn) rec_html1 += '<td class="w2ui-col-select" style="height: 0px"></td>' if (this.show.expandColumn) rec_html1 += '<td class="w2ui-col-expand" style="height: 0px"></td>' rec_html2 += '<td class="w2ui-grid-data w2ui-grid-data-spacer" col="start" style="height: 0px; width: 0px"></td>' if (this.reorderRows) rec_html2 += '<td class="w2ui-col-order" style="height: 0px"></td>' for (let i = 0; i < this.columns.length; i++) { let col = this.columns[i] tmph = '<td class="w2ui-grid-data" col="'+ i +'" style="height: 0px;"></td>' if (col.frozen && !col.hidden) { rec_html1 += tmph } else { if (col.hidden || i < this.last.colStart || i > this.last.colEnd) continue rec_html2 += tmph } } rec_html1 += '<td class="w2ui-grid-data-last" style="height: 0px"></td>' rec_html2 += '<td class="w2ui-grid-data-last" col="end" style="height: 0px"></td>' rec_html1 += '</tr>' rec_html2 += '</tr>' return [rec_html1, rec_html2] } // regular record let url = (typeof this.url != 'object' ? this.url : this.url.get) if (summary !== true) { if (this.searchData.length > 0 && !url) { if (ind >= this.last.searchIds.length) return ['',''] ind = this.last.searchIds[ind] record = this.records[ind] } else { if (ind >= this.records.length) return ['',''] record = this.records[ind] } } else { if (ind >= this.summary.length) return ['',''] record = this.summary[ind] } if (!record) return ['',''] if (record.recid == null && this.recid != null) { let rid = this.parseField(record, this.recid) if (rid != null) record.recid = rid } let isRowSelected = false if (sel.indexes.indexOf(ind) != -1) isRowSelected = true let rec_style = (record.w2ui ? record.w2ui.style : '') if (rec_style == null || typeof rec_style != 'string') rec_style = '' let rec_class = (record.w2ui ? record.w2ui.class : '') if (rec_class == null || typeof rec_class != 'string') rec_class = '' // render TR rec_html1 += '<tr id="grid_'+ this.name +'_frec_'+ record.recid +'" recid="'+ record.recid +'" line="'+ lineNum +'" index="'+ ind +'" '+ ' class="'+ (lineNum % 2 === 0 ? 'w2ui-even' : 'w2ui-odd') + ' w2ui-record ' + rec_class + (isRowSelected && this.selectType == 'row' ? ' w2ui-selected' : '') + (record.w2ui && record.w2ui.editable === false ? ' w2ui-no-edit' : '') + (record.w2ui && record.w2ui.expanded === true ? ' w2ui-expanded' : '') + '" ' + ' style="height: '+ this.recordHeight +'px; '+ (!isRowSelected && rec_style != '' ? rec_style : rec_style.replace('background-color', 'none')) +'" '+ (rec_style != '' ? 'custom_style="'+ rec_style +'"' : '') + '>' rec_html2 += '<tr id="grid_'+ this.name +'_rec_'+ record.recid +'" recid="'+ record.recid +'" line="'+ lineNum +'" index="'+ ind +'" '+ ' class="'+ (lineNum % 2 === 0 ? 'w2ui-even' : 'w2ui-odd') + ' w2ui-record ' + rec_class + (isRowSelected && this.selectType == 'row' ? ' w2ui-selected' : '') + (record.w2ui && record.w2ui.editable === false ? ' w2ui-no-edit' : '') + (record.w2ui && record.w2ui.expanded === true ? ' w2ui-expanded' : '') + '" ' + ' style="height: '+ this.recordHeight +'px; '+ (!isRowSelected && rec_style != '' ? rec_style : rec_style.replace('background-color', 'none')) +'" '+ (rec_style != '' ? 'custom_style="'+ rec_style +'"' : '') + '>' if (this.show.lineNumbers) { rec_html1 += '<td id="grid_'+ this.name +'_cell_'+ ind +'_number' + (summary ? '_s' : '') + '" '+ ' class="w2ui-col-number '+ (isRowSelected ? ' w2ui-row-selected' : '') +'"'+ (this.reorderRows ? ' style="cursor: move"' : '') + '>'+ (summary !== true ? this.getLineHTML(lineNum, record) : '') + '</td>' } if (this.show.selectColumn) { rec_html1 += '<td id="grid_'+ this.name +'_cell_'+ ind +'_select' + (summary ? '_s' : '') + '" class="w2ui-grid-data w2ui-col-select">'+ (summary !== true && !(record.w2ui && record.w2ui.hideCheckBox === true) ? ' <div>'+ ' <input class="w2ui-grid-select-check" type="checkbox" tabindex="-1" '+ (isRowSelected ? 'checked="checked"' : '') + ' style="pointer-events: none"/>'+ ' </div>' : '' ) + '</td>' } if (this.show.expandColumn) { let tmp_img = '' if (record.w2ui?.expanded === true) tmp_img = '-'; else tmp_img = '+' if ((record.w2ui?.expanded == 'none' || !Array.isArray(record.w2ui?.children) || !record.w2ui?.children.length)) tmp_img = '+' if (record.w2ui?.expanded == 'spinner') tmp_img = '<div class="w2ui-spinner" style="width: 16px; margin: -2px 2px;"></div>' rec_html1 += '<td id="grid_'+ this.name +'_cell_'+ ind +'_expand' + (summary ? '_s' : '') + '" class="w2ui-grid-data w2ui-col-expand">'+ (summary !== true ? `<div>${tmp_img}</div>` : '' ) + '</td>' } // insert empty first column rec_html2 += '<td class="w2ui-grid-data-spacer" col="start" style="border-right: 0"></td>' if (this.reorderRows) { rec_html2 += '<td id="grid_'+ this.name +'_cell_'+ ind +'_order' + (summary ? '_s' : '') + '" class="w2ui-grid-data w2ui-col-order" col="order">'+ (summary !== true ? '<div title="Drag to reorder"> </div>' : '' ) + '</td>' } let col_ind = 0 let col_skip = 0 while (true) { let col_span = 1 let col = this.columns[col_ind] if (col == null) break if (col.hidden) { col_ind++ if (col_skip > 0) col_skip-- continue } if (col_skip > 0) { col_ind++ if (this.columns[col_ind] == null) break record.w2ui.colspan[this.columns[col_ind-1].field] = 0 // need it for other methods col_skip-- continue } else if (record.w2ui) { let tmp1 = record.w2ui.colspan let tmp2 = this.columns[col_ind].field if (tmp1 && tmp1[tmp2] === 0) { delete tmp1[tmp2] // if no longer colspan then remove 0 } } // column virtual scroll if ((col_ind < this.last.colStart || col_ind > this.last.colEnd) && !col.frozen) { col_ind++ continue } if (record.w2ui) { if (typeof record.w2ui.colspan == 'object') { let span = parseInt(record.w2ui.colspan[col.field]) || null if (span > 1) { // if there are hidden columns, then no colspan on them let hcnt = 0 for (let i = col_ind; i < col_ind + span; i++) { if (i >= this.columns.length) break if (this.columns[i].hidden) hcnt++ } col_span = span - hcnt col_skip = span - 1 } } } let rec_cell = this.getCellHTML(ind, col_ind, summary, col_span) if (col.frozen) rec_html1 += rec_cell; else rec_html2 += rec_cell col_ind++ } rec_html1 += '<td class="w2ui-grid-data-last"></td>' rec_html2 += '<td class="w2ui-grid-data-last" col="end"></td>' rec_html1 += '</tr>' rec_html2 += '</tr>' return [rec_html1, rec_html2] }
Short description getRecordHTML should return an array but it doesn't
What is current behavior sometimes it return empty string but the result it's used as an array anyway.