Skip to content

Commit

Permalink
table.View: applyRendererOutput() => index => separate columnIndex & …
Browse files Browse the repository at this point in the history
…rowIndex #6345
  • Loading branch information
tobiu committed Jan 30, 2025
1 parent 11eb814 commit 316f290
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 23 deletions.
14 changes: 7 additions & 7 deletions src/grid/header/Button.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,14 @@ class Button extends BaseButton {
}

/**
* @param {Object} data
* @param {Neo.button.Base} data.column
* @param {Number} data.columnIndex
* @param {String} data.dataField
* @param {Object} data
* @param {Neo.button.Base} data.column
* @param {Number} data.columnIndex
* @param {String} data.dataField
* @param {Neo.grid.Container} data.gridContainer
* @param {Object} data.record
* @param {Number} data.rowIndex
* @param {Number|String} data.value
* @param {Object} data.record
* @param {Number} data.rowIndex
* @param {Number|String} data.value
* @returns {*}
*/
cellRenderer(data) {
Expand Down
23 changes: 13 additions & 10 deletions src/table/View.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,13 +116,14 @@ class View extends Component {
* @param {Object} data
* @param {String} [data.cellId]
* @param {Object} data.column
* @param {Number} data.columnIndex
* @param {Object} data.record
* @param {Number} data.index
* @param {Number} data.rowIndex
* @param {Neo.table.Container} data.tableContainer
* @returns {Object}
*/
applyRendererOutput(data) {
let {cellId, column, record, index, tableContainer} = data,
let {cellId, column, columnIndex, record, rowIndex, tableContainer} = data,
me = this,
cellCls = ['neo-table-cell'],
colspan = record[me.colspanField],
Expand All @@ -138,9 +139,10 @@ class View extends Component {

rendererOutput = column.renderer.call(column.rendererScope || tableContainer, {
column,
columnIndex,
dataField,
index,
record,
rowIndex,
tableContainer,
value: fieldValue
});
Expand Down Expand Up @@ -184,7 +186,7 @@ class View extends Component {
if (hasStore) {
cellId = me.getCellId(record, column.dataField)
} else {
cellId = vdom.cn[index]?.cn[me.getColumn(column.dataField, true)]?.id || Neo.getId('td')
cellId = vdom.cn[rowIndex]?.cn[me.getColumn(column.dataField, true)]?.id || Neo.getId('td')
}
}

Expand Down Expand Up @@ -267,7 +269,7 @@ class View extends Component {

for (i=0; i < colCount; i++) {
column = columns[i];
config = me.applyRendererOutput({column, record, index: rowIndex, tableContainer});
config = me.applyRendererOutput({column, columnIndex: i, record, rowIndex, tableContainer});

if (column.dock) {
config.cls = ['neo-locked', ...config.cls || []];
Expand Down Expand Up @@ -526,13 +528,13 @@ class View extends Component {
fieldNames = fields.map(field => field.name),
needsUpdate = false,
tableContainer = me.parent,
rowIndex = me.store.indexOf(record),
{selectionModel} = tableContainer,
{vdom} = me,
cellId, cellNode, column, index, scope;
cellId, cellNode, cellVdom, column, columnIndex, scope;

if (fieldNames.includes(me.colspanField)) {
index = me.store.indexOf(record);
me.vdom.cn[index] = me.createRow({record, rowIndex: index});
me.vdom.cn[index] = me.createRow({record, rowIndex});
me.update()
} else {
fields.forEach(field => {
Expand All @@ -547,11 +549,12 @@ class View extends Component {
// the vdom might not exist yet => nothing to do in this case
if (cellNode?.vdom) {
column = me.getColumn(field.name);
index = cellNode.index;
columnIndex = cellNode.index;
needsUpdate = true;
scope = column.rendererScope || tableContainer;
cellVdom = me.applyRendererOutput({cellId, column, columnIndex, record, rowIndex, tableContainer});

cellNode.parentNode.cn[index] = me.applyRendererOutput({cellId, column, record, index, tableContainer})
cellNode.parentNode.cn[columnIndex] = cellVdom
}
}
})
Expand Down
13 changes: 7 additions & 6 deletions src/table/header/Button.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,14 @@ class Button extends BaseButton {
}

/**
* @param {Object} data
* @param {Neo.button.Base} data.column
* @param {String} data.dataField
* @param {Number} data.index
* @param {Object} data.record
* @param {Object} data
* @param {Neo.button.Base} data.column
* @param {Number} data.columnIndex
* @param {String} data.dataField
* @param {Object} data.record
* @param {Number} data.rowIndex
* @param {Neo.table.Container} data.tableContainer
* @param {Number|String} data.value
* @param {Number|String} data.value
* @returns {*}
*/
cellRenderer(data) {
Expand Down

0 comments on commit 316f290

Please sign in to comment.