Adding dynamic checkboxes to the header of a table

Adding dynamic checkboxes to the header of a table

shewlessshewless Posts: 3Questions: 0Answers: 0
edited November 2012 in DataTables 1.9
Hi. I've seen other questions similar to this but they don't answer my questions.

You can see here I'm using the "sDom" to add some html to my header. Also I'm using jQueryUI so I need to use "H" and "F" to get my pretty styling.

[code]
$(document).ready(function() {
$('table.display').dataTable( {
"bJQueryUI": true,
"sDom": '<"H"lfr<"toolbar">>t<"F"ip>'
});
$("div.toolbar").html('want checkbox');
});
[/code]

What I'd like to know is two things:

1: How do I use javascript to add checkboxes (is there a better way than .html)
2: Really I would like to add these checkboxes in my "html" file itself (where the is defined. How can I do this in such a way that I can define the checkboxes in my html and have them included in the table header?

Thank you!

Replies

  • shewlessshewless Posts: 3Questions: 0Answers: 0
    edited November 2012
    .. I tried to demonstrate with acsii art but failed..
  • girishmrgirishmr Posts: 137Questions: 0Answers: 0
    edited November 2012
    You can use mRender to add check boxes

    http://www.datatables.net/ref
  • allanallan Posts: 63,389Questions: 1Answers: 10,450 Site admin
    Actually mRender won't help much with the header - that's for body cells only.

    To add items into header or footer cells you need to use standard DOM or jQuery methods - DataTables doesn't provide an API for that kind of manipulation.

    Allan
  • shewlessshewless Posts: 3Questions: 0Answers: 0
    Thank you. Actually I think I just need to figure out how to add check boxes using javascript and I'm good to go.
This discussion has been closed.