Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
caccia86 opened this issue Jun 28, 2024 · 0 comments
Open

Comments

@caccia86
Copy link

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
}
@caccia86 caccia86 changed the title Question: possibility to set Max value dynamically Question: possibility to set Max value dynamically (ui_table/ui_control) Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant