Number helper different based on data
Number helper different based on data
dougguthrie
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:
This discussion has been closed.
Answers
Just learned this myself
https://datatables.net/forums/discussion/50911/render-number-on-computed-value#latest
Thanks for the help! Good to know I was on the right path at least.