使用数据表修改TableTools

Modifying TableTools With Datatables

本文关键字:TableTools 修改 数据表      更新时间:2024-03-23

我正试图找出如何在复制按钮之前添加一个按钮,该按钮将始终是资源创建页面的链接。因此,如果它在/users上,并且在按钮列表中,如果用户单击"添加",那么它将转到/users/create。我该如何使用下面的代码做到这一点。我也有一些错误,并对其进行了研究,发现我的错误可能是由于我的文件呈现顺序造成的。我已将订单包括在下面。我希望有人能以某种方式帮助我。

TypeError: jQuery[g3g][((((Y2 + Z3) + G4) + p1) + F9e)] is undefined

...((Y2+G4+d6g+Z3+G4+A1e+U2+y8g))):jQuery&&!jQuery[g3g][(Y2+Z3+G4+p1+F9e)][(y8+t5e+...

dataTab...itor.js (line 475, col 170)
TypeError: DataTable.Editor is undefined

DataTable.Editor.defaults.display = "bootstrap";
editor....trap.js (line 8)

$('document').ready(function() {
    $('#myDatatable').dataTable({
        "pagingType": "full_numbers",
        "aoColumnDefs": [
            { 'bSortable': false, 'aTargets': [-1] },
            { 'sWidth': '30px', 'aTargets': ['idTH'] },
            { 'sWidth': '150px', 'aTargets': ['actionsTH', 'subTH'] },
            { 'sClass': 'text-center', 'aTargets': ['idTH', 'actionsTH', 'subTH'] }
        ],
        "iDisplayLength": 10,
        "aLengthMenu": [
            [5, 10, 25, 50, -1],
            [5, 10, 25, 50, "All"]
        ],
        dom: '<"dt-panelmenu clearfix"Tfr>t<"dt-panelfooter clearfix"ip>',
        "oTableTools": {
            "sSwfPath": "vendor/plugins/datatables/extensions/TableTools/swf/copy_csv_xls_pdf.swf"
        }
    });
});
<script src="http://myapp.app/vendor/jquery/jquery-1.11.1.min.js">
<script src="http://myapp.app/vendor/jquery/jquery_ui/jquery-ui.min.js">
<script src="http://myapp.app/assets/js/bootstrap/bootstrap.min.js">
<script src="http://myapp.app/assets/js/utility/utility.js">
<script src="http://myapp.app/assets/js/main.js">
<script type="text/javascript">
<script src="http://myapp.app/vendor/plugins/datatables/media/js/jquery.dataTables.js">
<script src="http://myapp.app/vendor/plugins/datatables/media/js/dataTables.bootstrap.js">
<script src="http://myapp.app/vendor/plugins/datatables/extensions/TableTools/js/dataTables.tableTools.min.js">
<script src="http://myapp.app/vendor/plugins/datatables/extensions/Editor/js/dataTables.editor.js">
<script src="http://myapp.app/vendor/plugins/datatables/media/js/dataTables.bootstrap.js">
<script src="http://myapp.app/vendor/plugins/datatables/extensions/Editor/js/editor.bootstrap.js">
<script src="http://myapp.app/assets/js/my-datatables.js">

首先,在<script>标记部分,您打开了一个标记,但从未关闭它。这可能是您没有定义的奇怪错误。与其说是脚本的位置或它们的顺序。

至于在UI中添加按钮,有时数据表解释的方式并不总是对你有利,因为这些按钮是基于闪存的。

为了举例,我想说:呼叫$('#myDatatable').dataTable({});

只需通过标准jquery方法附加元素即可。。

即:

$('#myDatatable').append('<div style="width:100px;height:30px;background-color:#F60;color:#fff;position:absolute;top:2px;right:275px;">Hello</div>');

同样,主要是为了举例说明,你可以根据需要进行调整,但如果你喜欢的话,你基本上可以把它紧贴在按钮旁边。你可能会把它放在按钮容器中,但接下来你会遇到额外的造型、定位等问题。如果你对整体有感觉,最容易接近所有按钮。