import * as React from 'react'; import { generatedata } from './generatedata'; import JqxButton from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxbuttons'; import JqxGrid, { IGridProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxgrid'; class App extends React.PureComponent<{}, IGridProps> { private myGrid = React.createRef(); constructor(props: {}) { super(props); this.excelBtnOnClick = this.excelBtnOnClick.bind(this); this.xmlBtnOnClick = this.xmlBtnOnClick.bind(this); this.csvBtnOnClick = this.csvBtnOnClick.bind(this); this.tsvBtnOnClick = this.tsvBtnOnClick.bind(this); this.htmlBtnOnClick = this.htmlBtnOnClick.bind(this); this.jsonBtnOnClick = this.jsonBtnOnClick.bind(this); this.pdfBtnOnClick = this.pdfBtnOnClick.bind(this); const source: any = { datafields: [ { name: 'firstname', type: 'string' }, { name: 'lastname', type: 'string' }, { name: 'productname', type: 'string' }, { name: 'available', type: 'bool' }, { name: 'date', type: 'date' }, { name: 'quantity', type: 'number' }, { name: 'price', type: 'number' } ], datatype: 'array', localdata: generatedata(100, false) }; this.state = { columns: [ { text: 'First Name', datafield: 'firstname', width: 130 }, { text: 'Last Name', datafield: 'lastname', width: 130 }, { text: 'Product', datafield: 'productname', width: 200 }, { text: 'Available', datafield: 'available', columntype: 'checkbox', width: 67, cellsalign: 'center', align: 'center' }, { text: 'Ship Date', datafield: 'date', width: 120, align: 'right', cellsalign: 'right', cellsformat: 'd' }, { text: 'Quantity', datafield: 'quantity', width: 70, align: 'right', cellsalign: 'right' }, { text: 'Price', datafield: 'price', cellsalign: 'right', 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 excelBtnOnClick() { this.myGrid.current!.exportdata('xls', 'jqxGrid'); }; private xmlBtnOnClick() { this.myGrid.current!.exportdata('xml', 'jqxGrid'); }; private csvBtnOnClick() { this.myGrid.current!.exportdata('csv', 'jqxGrid'); }; private tsvBtnOnClick() { this.myGrid.current!.exportdata('tsv', 'jqxGrid'); }; private htmlBtnOnClick() { this.myGrid.current!.exportdata('html', 'jqxGrid'); }; private jsonBtnOnClick() { this.myGrid.current!.exportdata('json', 'jqxGrid'); }; private pdfBtnOnClick() { this.myGrid.current!.exportdata('pdf', 'jqxGrid'); }; } export default App;