特定欄(列的話改為rows)

exportOptions: {
      columns: [ 2, 3 ]
}

或是 class選擇器

          columns: ['.export', '.important'] //by class selector

或是 內建參數

          columns: ':visible' //visible rows

--

dataTable的用法真的很奇扒,各種版本都不太一樣,官網討論區也找不出個甚麼鳥出來。

必須找出來之後自己記著!

--

Look for exportOptions.columnsexportOptions let you define a column-selector the same way as you would target specific columns for filtering and so on. Example, include only the third and fourth column in a PDF export :

 

$('#example').DataTable( {
  dom: 'Bfrtip',
  buttons: [
    {
      extend: 'pdf',
      exportOptions: {
        columns: [ 2, 3 ]
      }
    }
  ]
});

 

demo -> https://jsfiddle.net/r9Lqbhz4/

Other examples :

 

exportOptions: {
   columns: ':visible' //visible rows
}
exportOptions: {
   columns: ['.export', '.important'] //by class selector
}

 

And so on, see the above mentioned column-selector page,

As per comment: All visible columns except for one in particular :

 

exportOptions: {
   columns: ':visible:not(:eq(2))' 
}

 

Will include all visible columns except column #2, the third column. Be aware that the eq() column index is based on visible column indexes.

--

參考自 https://stackoverflow.com/questions/36953426/exclude-column-from-export-in-datatables-buttons

 

arrow
arrow
    全站熱搜
    創作者介紹
    創作者 dizzy03 的頭像
    dizzy03

    碎碎念

    dizzy03 發表在 痞客邦 留言(0) 人氣()