如何所有行从数据表使用Ajax出口? [英] How to export all rows from Datatables using Ajax?
问题描述
我在数据表使用的新功能:HTML5出口按钮。我用Ajax加载数据。
I am using new feature in Datatables: "HTML5 export buttons". I am loading data with Ajax.
https://datatables.net/extensions/buttons/examples/html5/ simple.html
的问题在于,它只有导出当前显示的网页。
The problem is that it only export the page that is currently displayed.
我出口是这样的:
buttons: [
{
extend: 'pdfHtml5',
text: 'PDF',
exportOptions: {
"columns": ':visible',
}
},
]
我如何可以导出所有行?
How can I export all rows?
推荐答案
据的数据表文档没有办法导出所有行,当您使用服务器端:
According to DataTables documentation there is no way to export all rows when you are using server side:
在服务器端处理特别注意:当使用服务器端的处理方式数据表(服务器端
)的选择 - 修改
具有在服务器上执行,因为所有的处理中选择的行的影响非常小(排序,搜索等)。因此,在客户端中存在的唯一的行的那些表中显示在任何一个时间,和选择器可以只选择那些在当前页上的行。
Special note on server-side processing: When using DataTables in server-side processing mode (
serverSide
) theselector-modifier
has very little effect on the rows selected since all processing (ordering, search etc) is performed at the server. Therefore, the only rows that exist on the client-side are those shown in the table at any one time, and the selector can only select those rows which are on the current page.
我身边这个工作通过添加'ALL'参数的长度菜单和培训最终用户之前做一个PDF(或XLS)出口显示所有记录:
I worked this around by adding an 'ALL' parameter to the length menu and training end users to display all records before doing a PDF (or XLS) export:
var table = $('#example').DataTable({
serverSide: true,
ajax: "/your_ajax_url/",
lengthMenu: [[25, 100, -1], [25, 100, "All"]],
pageLength: 25,
buttons: [
{
extend: 'excel',
text: '<span class="fa fa-file-excel-o"></span> Excel Export',
exportOptions: {
modifier: {
search: 'applied',
order: 'applied'
}
}
}
],
// other options
});
这篇关于如何所有行从数据表使用Ajax出口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!