[RESOLVED] How to display Yes or No rather than 1 or 0

[RESOLVED] How to display Yes or No rather than 1 or 0

VrutinVrutin Posts: 14Questions: 0Answers: 0
edited November 2013 in General
Currently the datatable displays the following:


However, I want to replace 1 with 'Yes' and 0 with 'No'.

I am using the Server-Side method.

Thanks in advance,
Vrutin

Replies

  • allanallan Posts: 63,540Questions: 1Answers: 10,476 Site admin
    Use the mRender option.

    Allan
  • VrutinVrutin Posts: 14Questions: 0Answers: 0
    Hi, Allan

    Sorry, but I am not able to understand how I would do this. I am quiet a noob on your library.

    Plus your jsbin live testing is dead, which is making it hard for me to understand.

    Vrutin
  • VrutinVrutin Posts: 14Questions: 0Answers: 0
    I have found the solution according to my needs, here's the code snippet for anyone in future looking for such functionality.

    [code]"aoColumnDefs": [
    {
    // `data` refers to the data for the cell (defined by `mData`, which
    // defaults to the column being worked with, in this case is the first
    // Using `row[0]` is equivalent.
    "mRender": function(data, type, row) {
    if (data === '1') {
    return 'Yes';
    } else {
    return 'No';
    }

    },
    "aTargets": [5]
    }
    ][/code]

    @Allan: I have another issue though, my columfilter doesn't seem to work anymore, is there any fix for that?

    Allan
  • VrutinVrutin Posts: 14Questions: 0Answers: 0
    I have found the solution to columnfilter not working, hope this helps anyone in future looking at this.
    I simply used jQuery to replace the 1's and 0's in select to Yes or No'

    [code] $(".select_filter option").each(function() {
    if ($(this).text() === '1') {
    $(this).text('Yes');
    }
    else if ($(this).text() === '0') {
    $(this).text('No');
    }
    });[/code]
This discussion has been closed.