Skip to content

Question: possibility to set Max value dynamically (ui_table/ui_control) #99

@caccia86

Description

@caccia86

node-red-node-ui-table v.0.4.3
node-red v.4.0.0
node-js v.18

Hi,
for a little project I'm trying to use the ui_table node and I started from the example flow "3 ui_control table.json" file.
Now, I would to set the Max value dynamically for example but for the moment I don't find any simple and effective solution.
Is it possibile to do that? If yes, with simple code?
I put below the code that I'm using in change node injected to the ui_table node (at Max row I put a comment).
Thanks in advance for whatever support.

{
    "tabulator": {
        "columnResized": "function(column){     var newColumn = {         field: column._column.field,         visible: column._column.visible,         width: column._column.width,         widthFixed: column._column.widthFixed,         widthStyled: column._column.widthStyled     }; this.send({topic:this.config.topic,ui_control:{callback:'columnResized',columnWidths:newColumn}}); }",
        "columnMoved": "function(column, columns){     var newColumns=[];     columns.forEach(function (column) {         newColumns.push({'field': column._column.field});     });     this.send({topic:this.config.topic,ui_control:{callback:'columnMoved',columns:newColumns}}); }",
        "groupHeader": "function (value, count, data, group) {return value + \"<span style='color:#d00; margin-left:10px;'>(\" + count + \" Termostat\"+((count>1) ? \"e\" : \"\") + \")</span>\";}",
        "columns": [
            {
                "formatterParams": {
                    "target": "_blank"
                },
                "title": "Macchina",
                "field": "room",
                "width": 100,
                "frozen": true
            },
            {
                "formatterParams": {
                    "target": "_blank"
                },
                "title": "Tipologia",
                "field": "name",
                "width": 100,
                "align": "center"
            },
            {
                "formatterParams": {
                    "target": "_blank"
                },
                "title": "Measurements",
                "columns": [
                    {
                        "formatterParams": {
                            "target": "_blank"
                        },
                        "title": "target",
                        "field": "SET_TEMPERATURE-value",
                        "formatter": "function(cell, formatterParams, onRendered){return cell.getValue()+' Pz';}",
                        "width": 100
                    },
                    {
                        "formatterParams": {
                            "target": "_blank",
                            "min": 0,
                            "max": 100,  --> to set dinamically with the previous field (SET_TEMPERATURE-value)
                            "color": [
                                "blue",
                                "green",
                                "red"
                            ],
                            "legend": "function (value) {return '&nbsp;&nbsp;'+value+' Pz';}",
                            "legendColor": "#101010",
                            "legendAlign": "left"
                        },
                        "title": "current",
                        "field": "ACTUAL_TEMPERATURE-value",
                        "formatter": "progress",
                        "width": 100
                    },
                    {
                        "formatterParams": {
                            "target": "_blank",
                            "min": 0,
                            "max": 99,
                            "color": [
                                "gray",
                                "orange",
                                "red"
                            ],
                            "legend": "function (value) {return (value>0)? '&nbsp;&nbsp;'+value+' %' : '-';}",
                            "legendColor": "#101010",
                            "legendAlign": "center"
                        },
                        "title": "Valve",
                        "field": "VALVE_STATE-value",
                        "formatter": "progress",
                        "width": 100
                    }
                ]
            },
            {
                "formatterParams": {
                    "target": "_blank"
                },
                "title": "Settings",
                "columns": [
                    {
                        "formatterParams": {
                            "target": "_blank"
                        },
                        "title": "Mode",
                        "field": "CONTROL_MODE-value",
                        "formatter": "function(cell, formatterParams, onRendered){     var html=\"<i class=\\\"\";     switch(cell.getValue()) {         case 0: html+=\"fa fa-calendar-check-o\"; break;         case 1: html+=\"fa fa-hand-o-up\"; break;         case 2: html+=\"fa fa-suitcase\"; break;         case 3: html+=\"fa fa-spinner fa-spin fa-fw\"; break;     }     html+='\\\"></i>';     return html; }",
                        "width": 100,
                        "align": "center"
                    }
                ]
            }
        ],
        "layout": "fitColumns",
        "movableColumns": true,
        "groupBy": ""
    },
    "customHeight": 12
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions