jquery datatable(TableTool) custom buttons calling events

fefe picture fefe · Aug 8, 2013 · Viewed 7.2k times · Source

Would be possible to use custom buttons in Jquery datatable using TableTool for custom events like saving , editing or deleting data. I do not really understand how to override the integrated buttons

  var oTable = $('#unis').dataTable({
        //"bProcessing": true,
        "bServerSide": true,
        "sAjaxSource": "index.php?...&<?php echo JSession::getFormToken() . '=1' ?>",
        "sDom": "<'row-fluid'<'span6'T><'span6'f>r>t<'row-fluid'<'span6'l><'span6'p>>",
        "sPaginationType": "bootstrap",
           "aoColumns":[
                    {"bSortable": false},
                    {"bSortable": false},
                    {"bSortable": true},
                    {"bSortable": true},
                    {"bSortable": false},
                  ],
        "oTableTools": {
        "aButtons": [ "delete selected", "export" ]
    }  

    });

Found it!

I had to use sExtends

"oTableTools": {
                        "sRowSelect": "multi",
                        "aButtons": [  
                                        {"sExtends":    "new_record","sButtonText": "Add"},
                                        {"sExtends":    "select","sButtonText": "Delete Recods",
                                        "fnClick": function (nButton, oConfig, oFlash) {
                                                    //delete stuff comes here 
                                                    alert('test');
                                                }

                                        }
                                    ]
                        }

Answer

fefe picture fefe · Jun 3, 2014

After making researches in Datatables API I found a workaround using sExtends you can extend buttons capability and add yours

"oTableTools": {
                        "sRowSelect": "multi",
                        "aButtons": [  
                               {"sExtends": "new_record","sButtonText": "Add"},
                               {"sExtends": "select","sButtonText": "Delete Recods",
                                 "fnClick": function (nButton, oConfig, oFlash) {
                                   //delete stuff comes here 
                                   alert('test');
                                           }

                                        }
                                    ]
                        }