We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22202
    • 23 Posts
    Hi,

    I am discovering all the power of datagrid widget and @select binding.

    I Have created a TV, i query the database like that :
    @SELECT * FROM `modx_web_user_attributes`


    And then i use the datagrid widget to display the data, everything works fine, and it display wonderfully the data.
    but some data need clearly to be manipulated before display like the last login date which is displayed in unix format : "1152622035".

    but how can i manipulate it, and still allow datagrid to display it ?

    thanks
      • 7923
      • 4,213 Posts
      I don’t know how flexible datagrid is, but I’ve heard from users that when you need more customized output, MakeTable is better. You can find some discussion here.


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 22202
        • 23 Posts
        Thanks,
        i’ve looked into maketable which seems interesant, but a little bit too complexe/not enough mature.
        i prefer to keep it easy.
        i’ve tried to use "@eval" i successfully get the data from the database, but when i try to do modifications datagrid doesn’t display anything...
        • You either need select specific fields and use a SQL function like FROM_UNIXTIME(unix_timestamp, format) in your SELECT statement, or you need to loop through the result set and build an array of the values you want to pass to datagrid, manipulating the value of the lastlogin element in each iteration (this assuming that datagrid accepts an array instead of a result set, though I’m not sure if it does or not).

          i.e.
          @SELECT email, fullname, FROM_UNIXTIME(lastlogin, '%Y %D %M %h:%i:%s') AS lastlogin FROM `[+prefix+]web_user_attributes`