import * as React from 'react'; import JqxButton from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxbuttons'; import JqxCheckBox from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxcheckbox'; 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(); constructor(props: {}) { super(props); this.myGridOnSort = this.myGridOnSort.bind(this); this.removeSortBtnOnClick = this.removeSortBtnOnClick.bind(this); this.sortBackGroundBtn = this.sortBackGroundBtn.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', type: 'string' }, { name: 'ShipAddress', map: 'm\\:properties>d\\:ShipAddress', type: 'string' }, { name: 'ShipCity', map: 'm\\:properties>d\\:ShipCity', type: 'string' }, { name: 'ShipCountry', map: 'm\\:properties>d\\:ShipCountry', type: 'string' } ], datatype: 'xml', id: { name: 'OrderID', map: 'm\\:properties>d\\:OrderID' }, record: 'content', root: 'entry', sortcolumn: 'ShipName', sortdirection: 'asc', url: 'orders.xml' }; this.state = { columns: [ { text: 'Ship Name', datafield: 'ShipName', width: 250 }, { text: 'Shipped Date', datafield: 'ShippedDate', width: 100, cellsformat: 'yyyy-MM-dd' }, { text: 'Freight', datafield: 'Freight', width: 80, 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 (
Remove Sort
Sort Background
Event Log:
); } private myGridOnSort(event: any): void { this.myPanel.current!.clearcontent(); const sortinformation = event.args.sortinformation; let sortdirection = sortinformation.sortdirection.ascending ? 'ascending' : 'descending'; if (!sortinformation.sortdirection.ascending && !sortinformation.sortdirection.descending) { sortdirection = 'null'; } const eventData = 'Triggered "sort" event
Column:' + sortinformation.sortcolumn + ', Direction: ' + sortdirection + '
'; this.myPanel.current!.prepend('
' + eventData + '
'); }; private removeSortBtnOnClick(): void { this.myGrid.current!.removesort(); }; private sortBackGroundBtn(event: any): void { this.myGrid.current!.setOptions({ showsortcolumnbackground: event.args.checked }); }; } export default App;