数据表:导出Excel按钮

时间:2011-10-07 07:10:51

标签: jquery jquery-ui jquery-datatables

有没有办法设置导出,PDF按钮的位置? (在桌子的右边,桌子的右下方,......)

http://www.datatables.net/release-datatables/extras/TableTools/

2 个答案:

答案 0 :(得分:4)

如果要移动整个表格工具栏,请在初始化时移动T字母。将整个工具栏推到最后的示例是:

$('#example').dataTable( {
    "sDom": '<"clear">lfrtipT'
} );

您无法重新配置DataTables以仅移动pdf按钮,但您可以使用标准JQuery将类“DTTT_button_pdf”的按钮带到某个新位置。可能类似于:

var pdfButton = $(".DTTT_button_pdf").detach();
$("#newPosition").append( pdfButton );

在此示例中,newPosition是您放置pdf按钮的元素的id。

答案 1 :(得分:0)

            var oTable = $("#tblViewMetadata").dataTable({
                "oLanguage": { "sSearch": "Search All Columns:" },
                "bJQueryUI": true,
                "bDestroy": true,
                "bPaginate": true,
                "bLengthChange": true ,
                "bFilter": true,
                "bSort": true,
                "bInfo": true,
                "bAutoWidth": true,
                "bDeferRender": true,
                "bRetrieve": true,
                "sScrollX": "500px",
                "sPaginationType": "full_numbers",
                "sDom": '<"H"lTfr>t<"F"ip>',

                "aLengthMenu": [[ 10, 25, 50,100, -1], [10, 25, 50,100, "All"]],
                "iDisplayLength": 10,
              ,
                "bSearchable": true,

                "oTableTools": {
                            "sSwfPath": "../Content/swf/copy_csv_xls.swf",
                            "aButtons": [
                             {
                                 "sExtends": "xls",
                                 "mColumns": [2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
                                 "sPdfOrientation": "landscape",
                                 "sButtonText": "Export to Excel",
                                 "oSelectorOpts": { filter: 'applied', order: 'current',page:'current' },
                             }
                            ]
                }, "bProcessing": true,
                "bDestroy": true,
                "aoColumnDefs": [{
                    'bSortable': false,
                    'aTargets': [0, 1]
                }], 







            });









<link href="~/Content/themes/base/demo_page.css" rel="stylesheet" />
<link href="~/Content/themes/base/demo_table_jui.css" rel="stylesheet" />

<link href="~/Content/themes/base/TableTools.css" rel="stylesheet" />
<link href="~/Content/themes/base/jquery-ui.css" rel="stylesheet" />

<script src="~/Scripts/js/jquery-1.8.2.js"></script>
<script src="~/Scripts/js/jquery.ui.core.js"></script>
<script src="~/Scripts/js/jquery.ui.widget.js"></script>
<script src="~/Scripts/js/jquery.ui.datepicker.js"></script>
<script src="~/Scripts/js/jquery.dataTables.js"></script>
<script src="~/Scripts/js/jquery.ui.dialog.js"></script>
<script src="~/Scripts/js/dataTables.tableTools.min.js"></script>
<script src="~/Scripts/js/ZeroClipboard.js"></script>
<script src="~/Scripts/js/TableTools.js"></script>


var allButton = $(" div.DTTT_container ").detach();
    $("#ExportBtn").append(allButton);