Replace 0 with No and 1 with Yes in Display
Replace 0 with No and 1 with Yes in Display

As already mentioned in the title I would like to change 0 with No and 1 with Yes I have seen a bit around but I have not arrived at any solution I have found only this but it does not work
{
"data": "hub_na",
orderable:false,
searchable:false,
render: function ( data, type, row ) {
if ( $(data.hub_na === 1) ) {
var i = "YES";
return i;
}
else {
var i = "NO";
return i;
}
}
},
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You have a couple problems with the if statement:
if ( $(data.hub_na === 1) ) {
. Thecolumns.render
docs explain that thedata
parameter is the data for the column. Instead ofdata.hub_na
usedata
. Also the$( .. )
is a jQuery method and shouldn't be in the if statement. Your if should like like this:Also to increase the efficiency of the render function you can eliminate the assignment statements to reduce the number of overall statements. Something like this:
Kevin