diff --git a/src/w2grid.js b/src/w2grid.js index 84cf0bcb0..cb9287b24 100644 --- a/src/w2grid.js +++ b/src/w2grid.js @@ -3263,7 +3263,7 @@ if (recEL.length <= 0) break; obj.expand(recid, event); } else { - var next = obj.nextCell(ind, columns[columns.length-1]); + var next = obj.nextCell(ind, columns[columns.length-1]); // columns is an array of selected columns if (!shiftKey && next == null) { this.selectNone(); next = this.columns.length-1; @@ -4062,6 +4062,7 @@ var rec = (isSummary ? this.summary[index] : this.records[index]); var col = this.columns[col_ind]; var cell = $(this.box).find('#grid_'+ this.name + '_data_'+ index +'_'+ col_ind); + if (rec == null) return false; // set cell html and changed flag cell.replaceWith(this.getCellHTML(index, col_ind, isSummary)); if (rec.w2ui && rec.w2ui.changes && rec.w2ui.changes[col.field] != null) { @@ -6645,9 +6646,15 @@ if (col_skip > 0) { col_ind++; if (this.columns[col_ind] == null) break; - record.w2ui.colspan[this.columns[col_ind].field] = 0; // need it for other methods + record.w2ui.colspan[this.columns[col_ind-1].field] = 0; // need it for other methods col_skip--; continue; + } else if (record.w2ui) { + var tmp1 = record.w2ui.colspan; + var 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) { @@ -6697,7 +6704,13 @@ var isRowSelected = false; var infoBubble = ''; if (sel.indexes.indexOf(ind) != -1) isRowSelected = true; - if (col_span == null) col_span = 1; + if (col_span == null) { + if (record && record.w2ui && record.w2ui.colspan && record.w2ui.colspan[col.field]) { + col_span = record.w2ui.colspan[col.field]; + } else { + col_span = 1; + } + } // expand icon if (col_ind == 0 && record && record.w2ui && Array.isArray(record.w2ui.children)) { var level = 0; @@ -7136,11 +7149,13 @@ var check = col_ind + 1; if (this.columns.length == check) return null; var tmp = this.records[index].w2ui; + var ccol = this.columns[col_ind]; + // if (tmp && tmp.colspan[ccol.field]) check += parseInt(tmp.colspan[ccol.field]) -1; // colspan of a column var col = this.columns[check]; - var span = (tmp && tmp.colspan ? tmp.colspan[col.field] : 1); + var span = (tmp && tmp.colspan && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); var edit = col ? col.editable : null; if (col == null) return null; - if (col && col.hidden || span == 0 + if (col && col.hidden || span === 0 || (editable == true && (edit == null || ['checkbox', 'check'].indexOf(edit.type) != -1))) { return this.nextCell(index, check, editable); } @@ -7152,10 +7167,10 @@ if (check < 0) return null; var tmp = this.records[index].w2ui; var col = this.columns[check]; - var span = (tmp && tmp.colspan ? tmp.colspan[col.field] : 1); + var span = (tmp && tmp.colspan && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); var edit = col ? col.editable : null; if (col == null) return null; - if (col && col.hidden || span == 0 + if (col && col.hidden || span === 0 || (editable == true && (edit == null || ['checkbox', 'check'].indexOf(edit.type) != -1))) { return this.prevCell(index, check, editable); } @@ -7164,6 +7179,7 @@ nextRow: function (ind, col_ind) { var sids = this.last.searchIds; + var ret = null; if ((ind + 1 < this.records.length && sids.length == 0) // if there are more records || (sids.length > 0 && ind < sids[sids.length-1])) { ind++; @@ -7171,14 +7187,22 @@ if ($.inArray(ind, sids) != -1 || ind > this.records.length) break; ind++; } - return ind; - } else { - return null; + // colspan + var tmp = this.records[ind].w2ui; + var col = this.columns[col_ind]; + var span = (tmp && tmp.colspan && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); + if (span == 0) { + ret = this.nextRow(ind, col_ind); + } else { + ret = ind; + } } + return ret; }, prevRow: function (ind, col_ind) { var sids = this.last.searchIds; + var ret = null; if ((ind > 0 && sids.length == 0) // if there are more records || (sids.length > 0 && ind > sids[0])) { ind--; @@ -7186,10 +7210,17 @@ if ($.inArray(ind, sids) != -1 || ind < 0) break; ind--; } - return ind; - } else { - return null; + // colspan + var tmp = this.records[ind].w2ui; + var col = this.columns[col_ind]; + var span = (tmp && tmp.colspan && !isNaN(tmp.colspan[col.field]) ? parseInt(tmp.colspan[col.field]) : 1); + if (span == 0) { + ret = this.prevRow(ind, col_ind); + } else { + ret = ind; + } } + return ret; }, selectionSave: function () { diff --git a/src/w2utils.js b/src/w2utils.js index 51c808963..0b2a1865c 100644 --- a/src/w2utils.js +++ b/src/w2utils.js @@ -28,6 +28,7 @@ var w2obj = w2obj || {}; // expose object to be able to overwrite default functi * - $().w2date(), $().w2dateTime() * == 1.5 * - added message +* - w2utils.keyboard is removed * ************************************************/ diff --git a/test/fields.html b/test/fields.html index e75cedd8f..1f2b3bc4e 100644 --- a/test/fields.html +++ b/test/fields.html @@ -90,9 +90,15 @@ openOnFocus: true, items: items, selected: [], - renderItem1: function (item, options, del) { - console.log('render', arguments); - return 'some' + del; + renderItem: function (item, options, del) { + return item.text + del; + }, + renderDrop: function (item) { + return '
' +item.text + '
'; + }, + select: function (event) { + console.log(event); + event.preventDefault(); }, // items: items onRequest: function (event) { diff --git a/test/grid.html b/test/grid.html index aefbeb4af..09c9b8c18 100644 --- a/test/grid.html +++ b/test/grid.html @@ -254,17 +254,17 @@ sdate: t, stime: dt, style1: 'background-color: #efefef', - w2ui: { children: [] }, + w2ui: { children: [], colspan: { personid: 2 } }, }); } - w2ui.grid.records[0].w2ui = { children: w2ui.grid.records.splice(10, 5), colspan: { personid: 2 } }; - w2ui.grid.records[2].w2ui = { children: w2ui.grid.records.splice(10, 3), colspan: { personid: 5 } }; - w2ui.grid.records[6].w2ui = { children: w2ui.grid.records.splice(10, 10), colspan: { personid: 7 } }; - w2ui.grid.records[6].w2ui.children[1].w2ui = { children: w2ui.grid.records.splice(10, 4) }; - w2ui.grid.records[6].w2ui.children[1].w2ui.children[2].w2ui = { children: w2ui.grid.records.splice(10, 4) }; - w2ui.grid.records[6].w2ui.children[1].w2ui.children[3].w2ui = { children: w2ui.grid.records.splice(10, 4) }; - w2ui.grid.records[6].w2ui.children[9].w2ui = { children: w2ui.grid.records.splice(10, 4) }; + // w2ui.grid.records[0].w2ui = { children: w2ui.grid.records.splice(10, 5), colspan: { personid: 2 } }; + // w2ui.grid.records[2].w2ui = { children: w2ui.grid.records.splice(10, 3), colspan: { personid: 5 } }; + // w2ui.grid.records[6].w2ui = { children: w2ui.grid.records.splice(10, 10), colspan: { personid: 7 } }; + // w2ui.grid.records[6].w2ui.children[1].w2ui = { children: w2ui.grid.records.splice(10, 4) }; + // w2ui.grid.records[6].w2ui.children[1].w2ui.children[2].w2ui = { children: w2ui.grid.records.splice(10, 4) }; + // w2ui.grid.records[6].w2ui.children[1].w2ui.children[3].w2ui = { children: w2ui.grid.records.splice(10, 4) }; + // w2ui.grid.records[6].w2ui.children[9].w2ui = { children: w2ui.grid.records.splice(10, 4) }; // w2ui.grid.records[4].w2ui.style = { fname: 'background-color: red' }; w2ui.grid.records[10].w2ui.summary = true; diff --git a/test/grid3.html b/test/grid3.html index 89c66c30b..4ca65772e 100644 --- a/test/grid3.html +++ b/test/grid3.html @@ -80,13 +80,13 @@ w2ui.grid.records[1].d = 'This is some long text in cell C and some and event more then this'; // w2ui.grid.records[1].e = '0'; // w2ui.grid.records[1].f = '1'; - w2ui.grid.records[1].w2ui = { colspan: { d: 1 }, softspan: { d: 3 } }; + w2ui.grid.records[1].w2ui = { colspan: { d: 3 } }; w2ui.grid.records[1].c = 'CC1'; - // w2ui.grid.records[2].w2ui = { colspan: { e: 4 } }; + w2ui.grid.records[2].w2ui = { colspan: { e: 4 } }; w2ui.grid.records[2].e = 'This is some long text in cell E'; - // w2ui.grid.records[3].w2ui = { colspan: { e: 3 } }; + w2ui.grid.records[3].w2ui = { colspan: { e: 3 } }; + w2ui.grid.records[6].w2ui = { colspan: { e: 2 } }; w2ui.grid.records[3].e = 'This is some long text in cell E'; - w2ui.grid.records[3].w2ui = { softspan: { e: 3 } }; w2ui.grid.records[4].w2ui = { summary: true }; w2ui.grid.records[1].w2ui = { style: { 1: 'background-color: red !important' }}; w2ui.grid.refresh();