Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add checkbox to jquery datatables header?

I would like to add a checkbox or span to a header of datatables table. I don't want to add it in the Html, I want that to do that from javascript at the initialization. Please suggest me.

like image 352
hanskishore Avatar asked Jan 04 '13 14:01

hanskishore


1 Answers

Well I did not want to change the html, it's not that a big a change I had to do, just had to add some html at the initialization.

    nTable = $('#tblExample').dataTable({
        "bJqueryUI": true,
        "bDestroy":true,
        "bPaginate": false,
        "bSortable": false,
        "aaData":testData,
        "aoColumns": [

                    {   "sTitle": "<input type='checkbox'></input>","mDataProp": null, "sWidth": "20px", "sDefaultContent": "<input type='checkbox' ></input>", "bSortable": false},
                    {   "mDataProp": "Year"},
                    {   "mDataProp": "Month"},
                    {   "mDataProp": "Savings"}

        ]
    });
like image 179
hanskishore Avatar answered Oct 24 '22 09:10

hanskishore