{hero}

buttons.exportInfo()

自:Buttons 1.4.0 起

取得許多不同按鈕類型通用的匯出元資訊。
請注意 - 此屬性需要 DataTables 的 Buttons 擴充功能。

描述

Buttons 最常用的功能是其顯示按鈕以匯出表格資料的能力 - 複製到剪貼簿、列印或本地建立的資料檔案。每個提供此功能的按鈕類型都有其自己的選項範圍(例如,CSV 按鈕類型可以將欄位分隔符號修改為 TSV 匯出),此外還有每個按鈕類型通用的選項。此方法提供這些通用選項,確保 API 的一致性以及程式碼的重複使用。

一般來說,您不太可能在匯出按鈕之外使用此方法,但它可公開用於自訂按鈕。

類型

function buttons.exportInfo( [ options ] )

描述
參數
傳回值

具有以下參數的物件

  • filename - 應由按鈕建立的任何檔案使用的檔案名稱
  • messageTop - 顯示在匯出資料內容頂部的訊息(在 title 之後)
  • messageBottom - 顯示在匯出資料內容結尾的訊息
  • title - 顯示在匯出資料中的標題。

範例

在自訂按鈕中取得匯出資訊

var table = new DataTable('#myTable', {
	buttons: [
		{
			text: 'My button',
			action: function (e, dt, button, config) {
				var info = dt.buttons.exportInfo();
				// Do something with the 'info' variable when creating custom export
			}
		}
	]
});