2016-08-26 2 views
-1

私のテーブルには、カラム値が"google"であり、ユーザーがそれをクリックするとGoogleのウェブサイトへのリンクになります。しかし、CSSVコンテンツをエクスポートする場合は、代わりにリンクとしてGoogleの値を変更したいと考えています。今のところ、csvのコンテンツは単なるGoogleテキストです。Datatables(2.1.4)aButtonsを使用してCSVコンテンツを変更する方法

ボタンの機能はどのようにするのですか?

私のコード:

"oTableTools": { 
     "sSwfPath": "http://cdn.datatables.net/tabletools/2.2.2/swf/copy_csv_xls_pdf.swf", 
     "aButtons": [ 
      { 
      "sExtends": "csv", 
      "sButtonText": "export csv", 
      } 
     ] 
} 

答えて

0

私は、CSVコンテンツに変更を加えるには、以下のようなaButtonsにfnCellRender機能を追加しました。

{ 
     "sExtends": "csv", 
     "sButtonText": "export CSV", 
     "sCharSet": "utf8",//solve csv chinese encoded problem 
     "bBomInc": true,//solve csv chinese encoded problem 
     "fnCellRender": function (sValue, iColumn, nTr, iDataIndex) { 
       if(sValue.toString().match("href")){ 
         return $(sValue).attr("href"); 
       } 
       return sValue; 
     }//to make some change to the cell content before export the csv 
} 
関連する問題