不添加导出csv和xls

时间:2013-01-05 13:47:26

标签: javascript object datatables

我使用DataTables方式进行动态sql连接。 我想添加按钮导出csv和xml,但它不会出现。 或者我误会了我。

oTable = $('#tbl_result').dataTable( 
        {
            "sDom": 'T<"top"fl>rt<"bottom"pi>' ,
            "sPaginationType": "full_numbers",
            "bAutoWidth"    : false,    
            "bProcessing": true,
            "bSortClasses"  : false, 
            "iDisplayLength": 15,
            "bStateSave"    : false,    
            "bServerSide": true,
            "oLanguage": {
                "sUrl": "/includes/js/DataTables.fr.js"
            },
            "sAjaxSource": "sql-objects.php",
           "oTableTools": {
                "aButtons": [ "csv", "xls" ],
                {
                    "aButtons":    [ "csv", "xls", "" ]
                    "sExtends":    "collection",
                }
            }, 
            "fnRowCallback": function( nRow, aData, iDataIndex ) 
            {
                $('td:eq(1)', nRow).html( DateFr(aData['date']) ) ;
                $('td:eq(2)', nRow).html( ( aData['etat'] == '0' ? 'Inscrit' :  'En attente') ) ;
                $('td:eq(3)', nRow).html( '<a user="' + aData['mail'] + '" class="delete" href="?id_abonne='+ aData['mail'] +'"><img border="0" class="icon16 infobulle" src="/back_office/images/template/icon16-delete.png"></a>');
            },
            "aoColumns"     :
            [
                { "mData": "mail" },
                { "mData": "date" },
                { "mData": "etat" },
                { "mData": "cle", "bSortable": false}
            ],
            "aaSorting"     :
            [
                [0,'desc']
            ]
        });

谢谢

1 个答案:

答案 0 :(得分:0)

您是否已将插件js文件添加到您的页面? DOWNLOAD LINK

另外我认为你需要包含swf文件,因为它是按钮的图像。

"oTableTools": {
            "sSwfPath": "/swf/copy_csv_xls_pdf.swf"
        }