How to render one column as a checkbox column?

How to render one column as a checkbox column?

ashishkulkarniashishkulkarni Posts: 9Questions: 0Answers: 0
edited January 2013 in DataTables 1.9
Hi guys,

I am using JSON Data as:

[code]
var testData = [
{
"name": "Project 01 Task 02",
"ticket_id": "111",
"ticket_date": "03/01/2013",
"end_date": "08/02/2013",
"ticket_type": "DEFECT",
"approval_status": "APPROVED",
"ticket_status": "COMPLETED"
},
{
"name": "Project 01 Task 03",
"ticket_id": "112",
"ticket_date": "03/01/2013",
"end_date": "08/02/2013",
"ticket_type": "DEFECT",
"approval_status": "APPROVED",
"ticket_status": "COMPLETED"
}
];
[/code]

My table initialisation is:
[code]
oTable = $('#dealTickets').dataTable({
"aaData": testData,
"aoColumns": [
{ "mDataProp": "name" },
{ "mDataProp": "ticket_id" },
{ "mDataProp": "ticket_date" },
{ "mDataProp": "end_date" },
{ "mDataProp": "ticket_type" },
{ "mDataProp": "approval_status" },
{ "mDataProp": "ticket_status"},
{ "mDataProp": "ticket_id"}
],
"sPaginationType": "full_numbers"
});
[/code]

Here, I am using the ticket_id 2 times. When I use it the second time, I would like to render it as a checkbox with name such as "check" + ticket_id and the ticket_id as the value.

The question is how can I do that?

I can use the form example to then detect which rows have been selected and do further processing.

Any help appreciated.

Best Regards,

Ashish.

Replies

  • ashishkulkarniashishkulkarni Posts: 9Questions: 0Answers: 0
    Achieved it by using jQuery to parse JSON data and populate the table and then simply using a basic datatables initialiser:

    [code]
    function populateTickets(data) {
    var output = '';
    var tickets = new Array();
    $.each(data, function(index, item) {
    if (tickets.indexOf(item.ticket_id) == -1) {
    output += ''
    + '' + item.name + ''
    + '' + item.ticket_id + ''
    + '' + item.ticket_date + ''
    + '' + item.end_date + ''
    + '' + item.ticket_type + ''
    + '' + item.approval_status + ''
    + '' + item.ticket_status + ''
    + ''
    + '';
    tickets.push(item.ticket_id);
    }
    });
    $('#dealTickets tbody').empty();
    $('#dealTickets tbody').append(output);
    }

    $(function () {

    populateTickets(testData);

    oTable = $('#dealTickets').dataTable({
    "sPaginationType": "full_numbers"
    });
    });
    [/code]
This discussion has been closed.