3

可以使用 TableTool 在 Jquery 数据表中使用自定义按钮来处理自定义事件,例如保存、编辑或删除数据。我不太明白如何覆盖集成按钮

  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" ]
    }  

    });

找到了!

我不得不使用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');
                                                }

                                        }
                                    ]
                        }
4

1 回答 1

1

在对 Datatables API 进行研究后,我发现了一种使用 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');
                                           }

                                        }
                                    ]
                        }
于 2014-06-03T11:00:18.857 回答