import * as React from 'react'; import { generatedata } from './generatedata'; import JqxButton from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxbuttons'; import JqxDataTable, { IDataTableProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxdatatable'; class App extends React.PureComponent<{}, IDataTableProps> { private myDataTable = React.createRef(); constructor(props: {}) { super(props); this.excelExport = this.excelExport.bind(this); this.xmlExport = this.xmlExport.bind(this); this.csvExport = this.csvExport.bind(this); this.tsvExport = this.tsvExport.bind(this); this.htmlExport = this.htmlExport.bind(this); this.jsonExport = this.jsonExport.bind(this); this.pdfExport = this.pdfExport.bind(this); const source: any = { dataFields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'available', type: 'bool' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' }, { name: 'date', type: 'date' } ], dataType: 'array', localData: generatedata(100, false) }; this.state = { columns: [ { text: 'First Name', dataField: 'firstname', width: 190 }, { text: 'Last Name', dataField: 'lastname', width: 190 }, { text: 'Product', dataField: 'productname', width: 177 }, { text: 'Available', dataField: 'available', width: 67, cellsAlign: 'center', align: 'center' }, { text: 'Ship Date', dataField: 'date', width: 90, align: 'right', cellsAlign: 'right', cellsFormat: 'd' }, { text: 'Quantity', dataField: 'quantity', width: 70, align: 'right', cellsAlign: 'right' }, { text: 'Price', dataField: 'price', cellsAlign: 'right', width: 100, align: 'right', cellsFormat: 'c2' } ], source: new jqx.dataAdapter(source) }; } public render() { return (
Export to Excel

Export to XML
Export to CSV

Export to TSV
Export to HTML

Export to JSON
Export to PDF
); } private excelExport(): void { this.myDataTable.current!.exportData('xls'); }; private xmlExport(): void { this.myDataTable.current!.exportData('xml'); }; private csvExport(): void { this.myDataTable.current!.exportData('csv'); }; private tsvExport(): void { this.myDataTable.current!.exportData('tsv'); }; private htmlExport(): void { this.myDataTable.current!.exportData('html'); }; private jsonExport(): void { this.myDataTable.current!.exportData('json'); }; private pdfExport(): void { this.myDataTable.current!.exportData('pdf'); }; } export default App;