首先是我正在开发的开发站点。这目前正在开发中,因此在您回答之前情况可能会发生变化:http ://wgarrisondev.mainstreethost.com/mage-product-redirects/public/
这是我的初始化代码:
// DataTable editor plugin initialization
var editor = new $.fn.dataTable.Editor( {
ajax: function ( method, url, data, successCallback, errorCallback ) {
successCallback( {"id": 4} );
},
table: "#grid-basic",
dom: 'Tlfrtip',
fields: [ {
label: "Request URL:",
name: "request-url"
}, {
label: "Target URL:",
name: "target-url"
}, {
label: "Category:",
name: "category"
}
]
});
// DataTable Initialization
var dataTable = $('#grid-basic').DataTable({
responsive: true,
columns: [
{ data: "request-url" },
{ data: "target-url" },
{ data: "category" },
{ data: null, defaultContent: '<button type="button" class="btn btn-xs btn-danger icon-delete"><span class="glyphicon glyphicon-remove"></span></button>', orderable: false }
]
});
// TableTools DataTable plugin initialization
var tableTools = new $.fn.dataTable.TableTools(dataTable, {
"sSwfPath": swfPath,
"aButtons": [
"copy",
{
"sExtends": "collection",
"sButtonText": "Export",
"aButtons": ["csv", "xls", "pdf"]
}
]
});
$( tableTools.fnContainer() ).addClass('pull-right').insertBefore('div.dataTables_wrapper');
// Set up editing of fields
$('#grid-basic').on( 'click', 'tbody td:not(:last-child)', function () {
editor.inline( this );
} );
// Set up Removal functionality
$('#grid-basic').on('click', 'button.icon-delete', function() {
dataTable.row($(this).parents('tr')).remove().draw();
});
我有一些非常奇怪的行为。复制按钮不起作用。但是,如果我选择其他三个选项之一,然后单击复制它可以正常工作。所有其他选项都可以正常工作。
更新-
我已经确定,在我至少单击一次集合之前,我没有放入集合中的任何按钮都不会起作用.....仍然一无所知
更新 2 - 所以我取得了一些进展。我的应用程序首先要求您选择商店类型和域。此时,我使用的表格被一个简单的 inline 隐藏了style="display: none"
。生成 url 的 jquery 后,将显示包含所有字段的表。如果我一开始没有隐藏我的表格,那么导出按钮都可以正常工作。然而,最初隐藏表格的一些事情搞砸了。显然我不能一直隐藏我的桌子,所以我仍在试图弄清楚为什么会发生这种情况。这个堆栈溢出有一个评分较低的答案,为我指明了正确的方向。