where can i add a checkbox in a row

where can i add a checkbox in a row

yeloyelo Posts: 3Questions: 0Answers: 0
edited September 2011 in General
Hi, all! i use datatables with django(refer to http://www.assembla.com/spaces/datatables_demo/wiki ), and i want to add a checkbox in every row. here is my html:
[code]


/* <![CDATA[ */

$(document).ready(function() {
/* Init the table */
$('#process_table').dataTable({
'sPaginationType': 'full_numbers',
"bServerSide": true,
"sAjaxSource": "{% url get_countries_list %}",
"aoColumns": [
{ "bSearchable": false},
{ "bSearchable": true},
{ "bSearchable": true},
{ "bSearchable": true},
{ "bSearchable": false},
{ "bSearchable": false},
{ "bSearchable": false},
{ "bSearchable": false},
{ "bSearchable": false},
]
});
} );





ID


Name


Formal name


Capital


Currency code


Currency name


Phone prefix


TLD


Check






[/code]

my question is where can i put the checkbox related code?

Replies

  • GregPGregP Posts: 500Questions: 10Answers: 0
    That's a broad question. ;-)

    You can theoretically add it all with JavaScript. That being the case, you can further decide to add it on a row-by-row basis (fnRowCallback; you will likely need an extra null column in aoColumns and your HTML to hold the checkbox), or if the table is only initialized once (you don't need to worry about refreshing it except on page refresh) you could even add it with an external JavaScript function to add all the checkbox cells and checkboxes.

    Or, you can add it with Python, injecting the extra cells/checkboxes on the server side.

    There's no "right" way to do it, just ways that are better suited to your purposes. Myself, I prefer the fnRowCallback method.
This discussion has been closed.