Format data from the database

Format data from the database

komserbeykomserbey Posts: 25Questions: 0Answers: 0
edited June 2013 in General
Hello,

I am looking for a while for a solution of my problem.
How can I format data that are extracted from the database?

Such as number format (I have now this kind of numbers 0.101515112219147725, I want 0.10)

Please help me out.

Regards,

K

Replies

  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    Do you want this number to be displayed in the table as ..1 or do you want to do the rounding on the server side? If you can't control the server data you can use mRender to alter the display of data in the table cells
  • komserbeykomserbey Posts: 25Questions: 0Answers: 0
    I 'cant'/'dont want' control it serverside. Is that the only way to control data?
  • aaronwaaronw Posts: 89Questions: 3Answers: 4
    In that case I would suggest mRender. You could write it (after defining the column you want to act on via aoColumnDefs or aoColumns):

    [code]
    "mRender": function ( data, type, full ) {
    return data.toFixed(2); //Rounds and keeps only 2 places after the decimal
    }
    [/code]
  • komserbeykomserbey Posts: 25Questions: 0Answers: 0
    Thank you Aaronw. I will fix it.

    Regards,

    Komserbey
This discussion has been closed.