import * as React from 'react'; import JqxGrid, { IGridProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxgrid'; import JqxPanel from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxpanel'; class App extends React.PureComponent<{}, IGridProps> { private myGrid = React.createRef(); private myPanel = React.createRef(); private pagingInfo = React.createRef(); private eventsLog = React.createRef(); constructor(props: {}) { super(props); this.onPageChanged = this.onPageChanged.bind(this); this.onPageSizeChanged = this.onPageSizeChanged.bind(this); const source: any = { datafields: [ { name: 'ShippedDate', map: 'm\\:properties>d\\:ShippedDate', type: 'date' }, { name: 'Freight', map: 'm\\:properties>d\\:Freight', type: 'float' }, { name: 'ShipName', map: 'm\\:properties>d\\:ShipName' }, { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress' }, { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity' }, { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry' } ], datatype: 'xml', id: 'm\\:properties>d\\:OrderID', record: 'content', root: 'entry', url: 'orders.xml' }; this.state = { columns: [ { text: 'Ship Name', datafield: 'ShipName', width: 250 }, { text: 'Shipped Date', datafield: 'ShippedDate', width: 230, cellsformat: 'D' }, { text: 'Freight', datafield: 'Freight', width: 130, cellsformat: 'f2', cellsalign: 'right' }, { text: 'Ship Address', datafield: 'ShipAddress', width: 350 }, { text: 'Ship City', datafield: 'ShipCity', width: 100 }, { text: 'Ship Country', datafield: 'ShipCountry', width: 101 } ], source: new jqx.dataAdapter(source) } } public render() { return (
Event Log:
Paging Details:
); } private onPageChanged(event: any): void { this.eventsLog.current!.style.display = 'block'; const loggedElements = document.getElementsByClassName('logged'); if (loggedElements.length >= 5) { this.myPanel.current!.clearcontent(); } const args = event.args; const eventData = 'pagechanged
Page:' + args.pagenum + ', Page Size: ' + args.pagesize + '
'; this.myPanel.current!.prepend('
' + eventData + '
'); // get page information. const paginginformation = this.myGrid.current!.getpaginginformation(); this.pagingInfo.current!.innerHTML = '
Page:' + paginginformation.pagenum + ', Page Size: ' + paginginformation.pagesize + ', Pages Count: ' + paginginformation.pagescount + '
'; } private onPageSizeChanged(event: any): void { this.eventsLog.current!.style.display = 'block'; this.myPanel.current!.clearcontent(); const args = event.args; const eventData = 'pagesizechanged
Page:' + args.pagenum + ', Page Size: ' + args.pagesize + ', Old Page Size: ' + args.oldpagesize + '
'; this.myPanel.current!.prepend('
' + eventData + '
'); // get page information. const paginginformation = this.myGrid.current!.getpaginginformation(); this.pagingInfo.current!.innerHTML = '
Page:' + paginginformation.pagenum + ', Page Size: ' + paginginformation.pagesize + ', Pages Count: ' + paginginformation.pagescount + '
'; } } export default App;