簡體   English   中英

使用數據表修改TableTools

[英]Modifying TableTools With Datatables

我試圖找出如何在復制按鈕之前添加一個按鈕的方法,該按鈕將始終是資源創建頁面的鏈接。 因此,如果它位於/ 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>標簽部分中,您打開了一個標簽,但從未關閉過。 這很可能是您未定義的奇怪錯誤。 與其說腳本的位置或順序,不如說是腳本的位置。

至於向用戶界面添加按鈕,有時數據表會以這種方式解釋它,但它並不總是對您有利,因為這些按鈕都是基於Flash的。

出於示例的原因,我要說$('#myDatatable').dataTable({}); :在調用$('#myDatatable').dataTable({});

只需通過標准jquery方法附加元素。

即:

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

再次主要是出於示例的目的,您可以根據需要進行調整,但是如果您希望可以將其放置在按鈕容器中,則可以基本上將其緊貼在這些按鈕旁邊,但是隨后您將陷入多余的樣式,定位等等。如果您對總體情況有所了解,那么最容易遍及所有地方。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM