2017-08-29 10 views
0

私は新しいタブでjQuery Datatablesのコレクションボタンの中にあるものを開こうとしていますが、うまくいきません。jQuery Datatablesを使って新しいタブでPDFを開く

$("#clientes").DataTable({ 
    dom: 'T<"clear">lfrtip', 
    tableTools: { 
     "aButtons": [ 
      { 
       "sExtends": "collection", 
       "sButtonText": "Generar Listado <span class='caret' />", 
       "aButtons": ['csv', 'xls', { 
        extend: 'pdfHtml5', 
        download: 'open' 
       }] 
      } 
     ], 
     "sSwfPath": "Content/DataTables/swf/copy_csv_xls_pdf.swf" 
     } 
    }); 

私はjQueryのDataTableののこのコレクションボタンでこの問題を解決する方法の任意のアイデア:これは私のjQueryの構成です

enter image description here

:?代わりに、それは私にこのような警告メッセージが表示さ

私はそれを動作させることを試みたために私のバンドル・クラス内のすべての参照を入れている:

enter image description here

答えて

0

問題はボタンタイプがundefinedになるように、誤って"sSwfPath"値から来るそうです:

"sSwfPath": "Content/DataTables/swf/copy_csv_xls_pdf.swf" 

ボタンのチェック条件はdataTables.tableTools.js_fnButtonDefinationsの内側に適用されます。

if (typeof TableTools.BUTTONS[ buttonSet[i] ] == 'undefined') { 
    alert("TableTools: Warning - unknown button type: "+buttonSet[i]); 
    continue; 
} 
buttonDef = $.extend({}, TableTools.BUTTONS[buttonSet[i]], true); 

あなたは、SWFファイルへの相対パスでUrlHelper.Contentを試すかDataTables CDN外部リソースから直接参照することができます。

// local content (in Razor view) 
"sSwfPath": "@Url.Content("~/Content/DataTables/swf/copy_csv_xls_pdf.swf")" 

// external resource (i.e. DataTables CDN) 
"sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf" 

はまた、あなたはpdf代わりのcollectionsExtendsを設定しようとすることができます

$("#clientes").DataTable({ 
    dom: 'T<"clear">lfrtip', 
    tableTools: { 
     "aButtons": [ 
      { 
       "sExtends": "pdf", 
       "sButtonText": "Generar Listado <span class='caret' />", 
       "aButtons": ['csv', 'xls', { 
        extend: 'pdfHtml5', 
        download: 'open' 
       }] 
      } 
     ], 
     "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf" 
    } 
}); 

例:JSFiddle Demo

次は、外部SWFリソースの読み込みに課される制限のために、ファイルセキュリティの問題です。 global security settings panelを開き、CDNリソースを「常に許可する」を選択するか、またはローカルに保存されたSWFの「場所を追加」(下の画像を参照)にsSwfPathに割り当てられたSWFパスを入力してから、そのパスの信頼を適用することを確認します(後でビューを更新する必要があります) 。

Adobe Flash Player Settings Manager

参照:

DataTables TableTools buttons not working correctly (simple example)

TableTools export in JQuery Datatables not working

jQuery dataTables - TableTools not working

jQuery TableTools not working

関連する問題