import * as React from 'react'; import JqxButton from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxbuttons'; import JqxGrid, { IGridProps, jqx } from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxgrid'; import JqxInput from 'jqwidgets-scripts/jqwidgets-react-tsx/jqxinput'; class App extends React.PureComponent<{}, IGridProps> { private myGrid = React.createRef(); private myInput = React.createRef(); private expandedGroupLog = React.createRef(); private collapsedGroupLog = React.createRef(); constructor(props: {}) { super(props); this.expandBtnOnClick = this.expandBtnOnClick.bind(this); this.collapseBtnOnClick = this.collapseBtnOnClick.bind(this); this.expandAllBtnOnClick = this.expandAllBtnOnClick.bind(this); this.collapseAllBtnOnClick = this.collapseAllBtnOnClick.bind(this); this.myGridOnGroupExpand = this.myGridOnGroupExpand.bind(this); this.myGridOnGroupCollapse = this.myGridOnGroupCollapse.bind(this); const source: any = { datafields: [ { name: 'CompanyName', map: 'm\\:properties>d\\:CompanyName', type: 'string' }, { name: 'ContactName', map: 'm\\:properties>d\\:ContactName', type: 'string' }, { name: 'ContactTitle', map: 'm\\:properties>d\\:ContactTitle', type: 'string' }, { name: 'City', map: 'm\\:properties>d\\:City', type: 'string' }, { name: 'PostalCode', map: 'm\\:properties>d\\:PostalCode', type: 'string' }, { name: 'Country', map: 'm\\:properties>d\\:Country', type: 'string' } ], datatype: 'xml', id: 'm\\:properties>d\\:CustomerID', record: 'content', root: 'entry', url: 'customers.xml' }; this.state = { columns: [ { text: 'Company Name', datafield: 'CompanyName', width: 250 }, { text: 'City', datafield: 'City', width: 120 }, { text: 'Country', datafield: 'Country' } ], source: new jqx.dataAdapter(source) } } public render() { return (
Expand Group
Collapse Group
Group:
Expand All
Collapse All
Event Log:
Expanded Group:
Collapsed Group:
); } private expandBtnOnClick(): void { const groupnum = this.myInput.current!.getOptions('value'); if (!isNaN(groupnum)) { this.myGrid.current!.expandgroup(groupnum); } }; private collapseBtnOnClick(): void { const groupnum = this.myInput.current!.getOptions('value'); if (!isNaN(groupnum)) { this.myGrid.current!.collapsegroup(groupnum); } }; private expandAllBtnOnClick(): void { this.myGrid.current!.expandallgroups(); }; private collapseAllBtnOnClick(): void { this.myGrid.current!.collapseallgroups(); }; private myGridOnGroupExpand(event: any): void { const args = event.args; this.expandedGroupLog.current!.innerHTML = 'Group: ' + args.group + ', Level: ' + args.level; } private myGridOnGroupCollapse(event: any): void { const args = event.args; this.collapsedGroupLog.current!.innerHTML = 'Group: ' + args.group + ', Level: ' + args.level } } export default App;