dataTable Grid를 CSV
으로 내보내려고합니다. 나는 수색을하고 나는 TableTools을 사용해야 만한다는 것을 알았다. 하지만이 플러그인이 없습니다. 이전에 나는 데이터 테이블의 버전을 훔치는되었다 jQuery dataTable을 CSV로 내보내는 방법은 무엇입니까?
steal("vendor/datatables/js/jquery.dataTables.js").then(
"vendor/datatables-plugins/js/dataTables.bootstrap.js",
"vendor/datatables-plugins/css/dataTables.bootstrap.css",
"vendor/datatables-colreorder/js/dataTables.colReorder.js",
"vendor/datatables-colreorder/css/dataTables.colReorder.css");
그래서 내가 검색이
link에서 발견 :이 확장은 은퇴되었으며 버튼 및 선택 확장으로 대체되었습니다
합니다. 문서는 기존 참조에 대해서만 유지됩니다. 새 프로젝트는 Tabletools보다 우선하여 에서 Buttons and Select를 사용해야합니다.
steal("vendor/datatables.net-buttons/js/dataTables.buttons.js").then( "vendor/datatables.net-buttons/js/buttons.flash.js", "vendor/datatables.net-buttons/js/buttons.colVis.js", "vendor/datatables.net-buttons/js/buttons.html5.js", "vendor/datatables.net-buttons/js/buttons.print.js", "vendor/datatables.net-buttons-dt/css/buttons.dataTables.css");
및 JQuery와 데이터 테이블에있는 버튼을 추가 :
그래서이 버튼을 갖는이 요구를 도용.
buttons: [
'csv', 'excel', 'pdf', 'print'
]
DataTable에 대한 코드는 다음과 같습니다 :
this.dataTable = this.$reportGrid.dataTable({
"aaData": aaData,
"aaSorting": aaSorting,
"aLengthMenu": this.options.pageSizes,
"aoColumns": aoColumns,
//"asStripeClasses": ["odd-row", "even-row"],
"autoWidth": true,
"bDestroy": true,
"bSort": this.options.allowSort === undefined ? true : this.options.allowSort,
"stateSave": true,
"bDeferRender": true,
"bScrollCollapse": true,
"footerCallback": function (nFoot, aData, iStart, iEnd, aiDisplay) {
if (that.data.totals) {
that.$tfoot.html(that.getTemplatePath(that.options.tmplFooter), that.data);
} else {
that.$tfoot.empty();
}
},
"fnStateLoadParams": function (oSettings, oData) {
oData.iStart = 0;
/* Reset the initial row displayed to be the first one. */
oData.aaSorting = oSettings.aaSorting;
/* Use the sorting supplied, not the one saved. */
oData.oSearch = oSettings.oSearch;
/* Use the search options supplied, not the ones saved. */
oData.ColReorder = [];
/* Empty this saved column reordering */
},
"pageLength": this.options.pageSize,
"displayStart": 0,
"language": {
"info": "Displaying rows _START_ to _END_ of _TOTAL_",
"lengthMenu": "Show _MENU_ rows at a time",
"paginate": {
"first": "First",
"last": "Last",
"previous": "Prev",
"next": "Next"
},
"searchPlaceholder": "Search..."
},
"sDom": this.buildsDom(),
buttons: [
'csv', 'excel', 'pdf', 'print'
],
"pagingType": "full_numbers",
"sScrollX": this.options.scrollX,
"drawCallback": function (o) {
if (that.options.autoHeight) {
that.adjustGridHeightToContainer();
}
that.removeTableInlineOverflowStyle();
if (that.element != null) {
can.trigger(that.element, 'grid_drawn');
}
}
});
을하지만 난 코드를 실행할 때, 버튼은 표시하지 않았다. 다음과 같이 시도했습니다.
"buttons": [
'csv', 'excel', 'pdf', 'print'
]
어떻게 사용할 수 있습니까 ?? 더 적은 변화와 함께 CSV 파일을 내보내는 방법이 있습니까?
, 그는/그녀는 언급한다. –