column value in footer

column value in footer

xshion13xshion13 Posts: 9Questions: 2Answers: 0

is there any way to add column value in footer? my latest column in mysql are a list of "dates" that would be good displaying only one value in footer as "Last Update: mm-dd-yyy hh:ss"

Answers

  • colincolin Posts: 15,237Questions: 1Answers: 2,599

    You could do something like this here. The footer can have anything in it.

    Colin

  • xshion13xshion13 Posts: 9Questions: 2Answers: 0
    edited March 2020

    thanks! this responds the first part of my question i am able to add tfooter in the table, in the example i have new Date() as parameter to show, but i am replacing

    new Date() to getDate(){
    return "somevalue";
    }

    where "somevalue" need to be the first row of date field.

    i tried this:

    function getDate(rdata) {
    var fectAct = rdata[13].toString;
    return fectAct;
    }

    but it returns:
    [object HTMLTableCellElement]

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    Maybe var fectAct = rdata[13].toString needs to be var fectAct = rdata[13].toString(). Note the () at the end. If this doesn't help the please update Colin's example to show the problem. This will allow us to help debug.

    Kevin

  • xshion13xshion13 Posts: 9Questions: 2Answers: 0

    yeh, my example uses ,toString(); and this is returning [object Object]

    btw i have created a file but i am not able to get running here:
    http://live.datatables.net/waweqaxo/1/edit

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921

    What value is rdata[13]? Use console.log in the function or the debugger to find out. That should help you figure out the next steps.

    Kevin

  • xshion13xshion13 Posts: 9Questions: 2Answers: 0

    that's the column13 from my table, i am using 14 columns (0 to 13), i have to hide the last because it gives "last update" in table, i am hiding this in order to show in footer.
    i tried to get info from the console but it's not giving me nothing. atm i am still fighting with this ^^

  • kthorngrenkthorngren Posts: 21,167Questions: 26Answers: 4,921
    edited March 2020

    You tried something like this?

    function getDate(rdata) {
      console.log('value: ', rdata[13]);
      var fectAct = rdata[13].toString();
    return fectAct;
    }
    

    Kevin

  • xshion13xshion13 Posts: 9Questions: 2Answers: 0
    edited March 2020

    thanks kevin!, it gave me that in console:

    where UltAct is part from:
    {"name":"John","Ult Act":"2020-03-13 17:05:42"}] in json url

  • xshion13xshion13 Posts: 9Questions: 2Answers: 0

    GOT IT!

    I Changed rdata to res and i noticed this is saving info from my columns ^^ so i was wrong. finally i am using this function to get the value from the first column:

    function getDate(res) {
                    console.log('value: ', res[1].UltAct);
                    var fectAct = res[1].UltAct;
                    console.log(fectAct);
                    return "Última Actualización: "+fectAct;
                }
    

    the method now returns this:

    thanks!

This discussion has been closed.