Skip to content

Commit 007c6cf

Browse files
authored
fix fo: UI-Table nested column headers appended if set multiple times over ui_control (#41)
* Try to fix the hight / scrolbar problem * ui_control can be set by multiple msgs + example * Bugfix headerVisible in tabulator.min.css * Bugfix headerVisble (version 0.3.3) * Turn off autoColumns if configured via ui_control * Fix for nested colum definitions * Fix for nested volum definition * columns merge fix * empty columns array
1 parent 4068d28 commit 007c6cf

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

node-red-node-ui-table/node.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ var mergeTabulator = function(target,source) {
2828
// handle the columns array to merge columns if the field property matches. Otherwise push a new column
2929
if (element==='columns' && Array.isArray(source[element])){
3030
source[element].forEach(sourceElement => {
31-
let index = target[element].findIndex(targetElement => (targetElement.field && sourceElement.field && targetElement.field===sourceElement.field));
31+
let index = target[element].findIndex(targetElement => (
32+
(targetElement.field && sourceElement.field && targetElement.field===sourceElement.field) || // normal column object
33+
(targetElement.title && sourceElement.title && targetElement.title===sourceElement.title) // parent object with nested columns
34+
));
3235
if (index<0) { // add new column
3336
index=target[element].push({})-1;
3437
}
@@ -110,10 +113,16 @@ module.exports = function (RED) {
110113
"columns":config.columns
111114
}};
112115
}
113-
// instead of
114-
// config.ui_control=Object.assign(config.ui_control,msg.ui_control);
115116
// use mergeTabulator to correctly merge columns arrays if field property matches
116117
mergeTabulator(config.ui_control,msg.ui_control);
118+
119+
// delete column definitions by sending a empty columns array (requires page reload)
120+
if (msg.ui_control.tabulator && msg.ui_control.tabulator.columns && Array.isArray(msg.ui_control.tabulator.columns) &&
121+
msg.ui_control.tabulator.columns.length==0) {
122+
123+
config.ui_control.tabulator.columns=[];
124+
config.ui_control.tabulator.autoColumns=true;
125+
}
117126
}
118127
return { msg: {
119128
payload: value,

node-red-node-ui-table/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "node-red-node-ui-table",
3-
"version": "0.3.5",
3+
"version": "0.3.6",
44
"description": "Table UI widget node for Node-RED Dashboard",
55
"author": "Kazuhito Yokoi",
66
"contributors": ["Dave Conway-Jones","@hotNipi","@Christian-Me"],

0 commit comments

Comments
 (0)