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'; class App extends React.PureComponent<{}, IGridProps> { private myGrid = React.createRef(); private groupNum = React.createRef(); private expandedGroup = React.createRef(); private collapsedGroup = React.createRef(); constructor(props: {}) { super(props); this.onExpandGroup = this.onExpandGroup.bind(this); this.onCollapseGroup = this.onCollapseGroup.bind(this); this.onExpandAllGroup = this.onExpandAllGroup.bind(this); this.onCollapseAllGroup = this.onCollapseAllGroup.bind(this); this.onGroupExpand = this.onGroupExpand.bind(this); this.onGroupCollapse = this.onGroupCollapse.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 Group
Collapse All Groups
Event Log:
Expanded Group:
Collapsed Group:
); } private onExpandGroup(): void { const groupNum = this.groupNum.current!.value; this.myGrid.current!.expandgroup(groupNum); } private onCollapseGroup(): void { const groupNum = this.groupNum.current!.value; this.myGrid.current!.collapsegroup(groupNum); } private onExpandAllGroup(): void { this.myGrid.current!.expandallgroups(); } private onCollapseAllGroup(): void { this.myGrid.current!.collapseallgroups(); } private onGroupExpand(event: any): void { const args = event.args; this.expandedGroup.current!.innerHTML = 'Group: ' + args.group + ', Level: ' + args.level; } private onGroupCollapse(event: any): void { const args = event.args; this.collapsedGroup.current!.innerHTML = 'Group: ' + args.group + ', Level: ' + args.level; } } export default App;