Help to sort by a column the data entered in node ui_tablet

Hello.
I present you my problem
I have a Ui_tablet node that works great.

.
But I am not able to sort the data from newest to oldest (in the image you can see that the "Timestamp" field is sorted from oldest to newest, just the opposite of how I want).
I give some data on how I fill the table and how I have configured it.

  1. Column configuration

  1. Add a row
msg.payload={
    command:"addRow",
    arguments: [
        
            msg.payload,
            false
    ],
    returnPromise: true
}
return msg;

Where msg .payload is (by example)

var now = new Date();
var yyyy = now.getFullYear();
var mm = now.getMonth() < 9 ? "0" + (now.getMonth() + 1) : (now.getMonth() + 1); // getMonth() is zero-based
var dd  = now.getDate() < 10 ? "0" + now.getDate() : now.getDate();
var hh = now.getHours() < 10 ? "0" + now.getHours() : now.getHours();
var mmm  = now.getMinutes() < 10 ? "0" + now.getMinutes() : now.getMinutes();
var ss  = now.getSeconds() < 10 ? "0" + now.getSeconds() : now.getSeconds();
msg.payload = {
    //"timestamp" : + yyyy + "/"+ mm + "/" + dd + "  " + hh + ":"+ mmm + ":" + ss ,
    "timestamp" : + dd + "/"+ mm + "/" + yyyy + "  " + hh + ":"+ mmm + ":" + ss ,
    "Evento": "Orden HMI sobre DBT , APERTURA",
    "status" : "#1FFDFE",
}
return msg;

Can you guide me on my doubt?

Hi,

AddRow adds rows to the end or at the top

The second argument is optional and determines whether the row is added to the top or bottom of the table. A value of true will add the row to the top of the table, a value of false will add the row to the bottom of the table.

as described here You send false so new lines are added to the bottom resulting in the table sorted ascending.

you can trigger the sort by setSort()

and by using the arrow keys on the header. (if you use these it is perhaps good to know that you can receive the current sorting by getSorters() and then add your new lines at the top or at the end depending which state is set. Maybe this can be tricky if you have multiple clients showing the data because they might be not in sync,

How to scroll to the new line I think I already answered here Problem with data displayed in UI-Table when switching Tabs - #7 by Christian-Me

thank you now it's working

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.