ruby on rails アプリケーションで Datatable を使用しています。私はここにあるのと同じものに従います..
https://github.com/rweng/jquery-datatables-rails
そして、私のデータテーブルの並べ替えと検索は正しく機能しています。しかし、テーブル ヘッダーにテーブル ツール オプション (例: copy、csv、excel、pdf、save ) が表示されません。
こんな風にテーブルを見せたいのですが……。
助けてください。
ruby on rails アプリケーションで Datatable を使用しています。私はここにあるのと同じものに従います..
https://github.com/rweng/jquery-datatables-rails
そして、私のデータテーブルの並べ替えと検索は正しく機能しています。しかし、テーブル ヘッダーにテーブル ツール オプション (例: copy、csv、excel、pdf、save ) が表示されません。
こんな風にテーブルを見せたいのですが……。
助けてください。
ButtonsおよびSelect拡張機能 ( source )の TableTools は廃止されますが、これはdomオプションの例の少し新しいバージョンです。
var oTable = $('#my-table').dataTable({
autoWidth: false,
autoHeight: false,
paging: false,
dom: 'TCfrtip', // <-- Update letters for whichever extensions you want to use
responsive: false,
searching: true,
ordering: true,
stateSave: true,
scrollY: 550,
scrollX: true,
scrollCollapse: true,
fixedHeader: false,
buttons: [
'copyHtml5',
'csvHtml5',
'excelHtml5',
'pdfHtml5'
],
columnDefs: [{
targets: 'no-sort', // disable sorting on class="no-sort"
orderable: false
}],
drawCallback: function (settings) { }
});
解決策は、これを追加することです:
"sDom": '<"H"TCfr>t<"F"ip>'
あなたのjavascriptの中に。列の表示/非表示でもうまく機能します。列の表示/非表示を使用していない場合は、大文字の「C」を削除できます。
例 (列の表示/非表示):
// Users
$("#users-datatable").dataTable({
"bStateSave": true,
"bJQueryUI": true,
"sPaginationType": "full_numbers",
"bProcessing": true,
"bServerSide": true,
"sAjaxSource": $('#users-datatable').data('source'),
"bScrollInfinite": true,
"bScrollCollapse": true,
"iDisplayLength": 100,
"sScrollY": "500px",
"sScrollX": "100%",
"sDom": '<"H"TCfr>t<"F"ip>',
"oTableTools": {
"aButtons": [
"copy",
"csv",
"xls",
{
"sExtends": "pdf",
"sPdfOrientation": "landscape",
"sPdfMessage": "Your custom message would go here."
},
"print"
]
}
});
うまくいけば、これは誰かを助けるでしょう。