Checkbox column in DataTables

Checkbox column in DataTables

rsreaganrsreagan Posts: 7Questions: 0Answers: 0
edited December 2012 in DataTables 1.9
I am loading my datatable through sAjaxSource, and I'm specifying my columns individually with aoColumns. In the JSON returned from the server, I'm passing in a boolean value represented by a 1 or a 0. This is arbitrary - I could represent it any way I like. Can someone explain to me how I can display a checkbox in my datatable? I am also using the Editor, and need to be able to update the value within the Editor edit dialog. I don't need to create new rows though. I've been through the docs and am still not sure? Anyone? Thanks in advance!

Replies

  • rsreaganrsreagan Posts: 7Questions: 0Answers: 0
    I think I've found the answer. I'm using the following function in aoColumns for my checkbox column:

    [code]
    ...
    { "mData": "IsAssociated", "mRender": function (data, type, full ) {
    if (data == true)
    {
    return '';
    }
    else
    {
    return '';
    }
    }
    },
    ...
    [/code]

    Is this the preferred way to accomplish this?
  • allanallan Posts: 63,498Questions: 1Answers: 10,471 Site admin
    A mData and mRender combination is exactly what I would suggest - looks good to me :-). You might need to add a name or id to your checkbox as well (or perhaps just refer to the TR element), but that's certainly along the right lines.

    Allan
This discussion has been closed.