Skip to content

Commit

Permalink
wc: fix providing custom data to columns extensions #TASK-5066
Browse files Browse the repository at this point in the history
  • Loading branch information
jmjuanes committed Oct 25, 2023
1 parent d474f3d commit b2a37b6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/webcomponents/extensions-manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ export default {
// Returns a list of custom columns for the specified component
// @param {array} columns - An array of columns where new columns will be injected
// @param {string} componentId - ID of the component where this new column will be injected
// @param {function} checkColumnVisible: function to determine if column is visible or not
// @param {function} getData: function to obtain custom data for columns
// @return {array} columns - a list of columns configurations
injectColumns(columns, componentId, checkColumnVisible, data) {
injectColumns(columns, componentId, checkColumnVisible, getData) {
// We need to check if we are in a single or multiple row levels
const hasGroupedRows = columns.length === 2 && (Array.isArray(columns[0]) && Array.isArray(columns[1]));
this.getByType(this.TYPES.COLUMN)
Expand All @@ -84,12 +86,12 @@ export default {
[newColumns].flat().forEach(newColumn => {
const group = hasGroupedRows ? columns[index] : columns;
const position = newColumn.position ?? group.length;
const columnData = data[extension.id] || {};
const config = {
...newColumn.config,
// We need to overwrite the formatter to provide custom data of this columns
formatter: (value, row, index) => {
return newColumn.config.formatter(value, row, index, columnData);
const data = typeof getData === "function" ? getData() : {};
return newColumn.config.formatter(value, row, index, data?.[extension.id]);
},
};
// check if we have provided a function to check if column is visible
Expand Down

0 comments on commit b2a37b6

Please sign in to comment.