Using mRender to display boolean value

Using mRender to display boolean value

jacomojacomo Posts: 2Questions: 2Answers: 0
edited March 2018 in Free community support

Hello,
I want to change the true/false value displayed to yes/no .
I am using the mRender as follows

<script>
var table = $('#productTable').DataTable({
    "aoColumnDefs": [{
        "aTargets": [5] // Here we have to give the target column for which value conversion(manipulation) takes place
            ,
        "mRender": function(data, type, row) {
            return (row[5] = "true") ?
                "yes" : "no";
        }
    }]
});

but I always get yes no matter if the boolean value is true or false. Can you help please?

Answers

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

    Try it with == on line 7 - = is just an assignment.

    C

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    You need row[5] == true (comparison operator)
    otherwise you are just assigning the value "true".

This discussion has been closed.