node-red / node-red-ui-nodes

Additional nodes for Node-RED Dashboard
Apache License 2.0
122 stars 83 forks source link

node-red-node-ui-table: sorting on row number doesn't work #79

Closed oliv3 closed 2 years ago

oliv3 commented 2 years ago

Which node are you reporting an issue on?

node-red-node-ui-table

What are the steps to reproduce?

Run this flow:

[
    {
        "id": "f6f2187d.f17ca8",
        "type": "tab",
        "label": "Flow 1",
        "disabled": false,
        "info": ""
    },
    {
        "id": "9573159384400fb0",
        "type": "ui_table",
        "z": "f6f2187d.f17ca8",
        "group": "f05f0cebf73e263f",
        "name": "",
        "order": 0,
        "width": "6",
        "height": "11",
        "columns": [
            {
                "field": "",
                "title": "N°",
                "width": "",
                "align": "left",
                "formatter": "rownum",
                "formatterParams": {
                    "target": "_blank"
                }
            },
            {
                "field": "foo",
                "title": "Foo",
                "width": "",
                "align": "left",
                "formatter": "plaintext",
                "formatterParams": {
                    "target": "_blank"
                }
            }
        ],
        "outputs": 0,
        "cts": false,
        "x": 810,
        "y": 220,
        "wires": []
    },
    {
        "id": "b1c16a6b87874fc2",
        "type": "inject",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "props": [
            {
                "p": "payload"
            },
            {
                "p": "topic",
                "vt": "str"
            }
        ],
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "topic": "",
        "payload": "",
        "payloadType": "date",
        "x": 420,
        "y": 220,
        "wires": [
            [
                "975a87870eeed0a5"
            ]
        ]
    },
    {
        "id": "975a87870eeed0a5",
        "type": "function",
        "z": "f6f2187d.f17ca8",
        "name": "",
        "func": "msg.payload = [\n    { foo: 1 },\n    { foo: 12 },\n    { foo: 11 },\n    { foo: 19 },\n    { foo: 2 },\n    { foo: 234 },\n    { foo: 56 },\n    { foo: 7 }\n]\n\nreturn msg",
        "outputs": 1,
        "noerr": 0,
        "initialize": "",
        "finalize": "",
        "libs": [],
        "x": 620,
        "y": 220,
        "wires": [
            [
                "9573159384400fb0"
            ]
        ]
    },
    {
        "id": "f05f0cebf73e263f",
        "type": "ui_group",
        "name": "Default",
        "tab": "0f07e8bf8e2b9d66",
        "order": 1,
        "disp": true,
        "width": "6",
        "collapse": false,
        "className": ""
    },
    {
        "id": "0f07e8bf8e2b9d66",
        "type": "ui_tab",
        "name": "Home",
        "icon": "dashboard",
        "disabled": false,
        "hidden": false
    }
]

What happens?

Sorting on the Foo column works, but it does not on the column

What do you expect to happen?

The column should be sorted

Please tell us about your environment:

dceejay commented 2 years ago

The tabulator library treats rownumber types as not part of the data (just as a label) and so does not seem to allow sorting on them - the workaround being to actually create a numbered row index in your data and sort on that.

eg see https://github.com/olifolkerd/tabulator/issues/1359

oliv3 commented 2 years ago

Yeah I ended up doing the same workaround.