This repository was archived by the owner on May 30, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 78
export()
Karl edited this page Oct 21, 2017
·
5 revisions
NOTE: The export() method has been deprecated and will be removed in v2.0 in favour of the Exportable extension.
Export the table data to various formats.
/**
* @param {Object} options User options
* @return {Boolean}
*/
datatable.export(options);The options argument must be an object of which the only required property is the type property which accepts either csv, txt, json or sql as it's value. The rest are optional:
{
type: "csv" // "csv", "txt", "json" or "sql"
download: true, // trigger download of file or return the string
skipColumn: [], // array of column indexes to skip
// csv
lineDelimiter: "\n", // line delimiter for csv type
columnDelimiter: ",", // column delimiter for csv type
// sql
tableName: "myTable", // SQL table name for sql type
// json
replacer: null, // JSON.stringify's replacer parameter for json type
space: 4 // JSON.stringify's space parameter for json type
};// Export the current page as a .csv file
dataTable.export({
type: "csv",
filename: "my-csv-file"
selection: dataTable.currentPage
});// Export pages 1-5 as an .sql file
dataTable.export({
type: "sql",
tableName: "sql_users",
selection: [1,2,3,4,5]
});// Export to .json file
dataTable.export({
type: "json",
});// Export to json string, omitting the 1st, 3rd and 5th columns
var json = dataTable.export({
type: "json",
skipColumn: [0,2,4],
download: false // return formatted string instead of file
});- datatable.init
- datatable.refresh
- datatable.update
- datatable.page
- datatable.sort
- datatable.perpage
- datatable.search
- perPage
- perPageSelect
- nextPrev
- prevText
- nextText
- firstLast
- firstText
- lastText
- searchable
- sortable
- truncatePager
- fixedColumns
- fixedHeight
- columns
- data
- ajax
- labels
- layout
- header
- footer
- table
- head DEPRECATED
- body DEPRECATED
- foot DEPRECATED
- wrapper
- container
- pagers
- headings
- options DEPRECATED
- initialized
- isIE DEPRECATED
- data
- activeRows DEPRECATED
- dataIndex
- pages
- hasRows
- hasHeadings
- currentPage
- totalPages
- onFirstPage
- onLastPage
- searching
- searchData