Number helper different based on data

Number helper different based on data

dougguthriedougguthrie Posts: 10Questions: 7Answers: 0

I have a column where the value can either be a percentage or a number. The percentage will be any number <= 100. Is it possible to pick between two renderers, percentage and number, based on the data? I've tried the following without any luck:

render: function( data, type, row ) {
    if ( data <= 100 ) {
        return $.fn.dataTable.render.number( '', '.', 2, '', '%' )
    } else {
        return $.fn.dataTable.render.number( ',', '.', 0 )
    }
}

This question has accepted answers - jump to:

Answers

This discussion has been closed.