import * as React from 'react'; import { OrgChart, OrgChartExpandChangeEvent, processOrgChartItems } from '@progress/kendo-react-orgchart'; const idField = 'id'; const childrenField = 'employees'; const titleField = 'title'; const subtitleField = 'name'; const tree = [ { id: 1, name: 'Gevin Bell', title: 'CEO', avatar: 'https://demos.telerik.com/kendo-ui/content/web/treelist/people/1.jpg', employees: [ { id: 2, name: 'Carol Baker', title: 'CMO', parentId: 1, avatar: 'https://demos.telerik.com/kendo-ui/content/web/treelist/people/3.jpg' }, { id: 3, name: 'Kendra Howell', title: 'CFO', parentId: 1, avatar: 'https://demos.telerik.com/kendo-ui/content/web/treelist/people/4.jpg' } ] } ]; const App = () => { const [expand1, setExpand1] = React.useState({ ids: [1, 2, 3], idField: 'id' }); const [expand2, setExpand2] = React.useState({ ids: [1, 2, 3], idField: 'id' }); const onExpandChange1 = (event: OrgChartExpandChangeEvent) => { let ids = expand1.ids.slice(); const index = ids.indexOf(event.item.id); index === -1 ? ids.push(event.item.id) : ids.splice(index, 1); setExpand1({ ids, idField: 'id' }); }; const onExpandChange2 = (event: OrgChartExpandChangeEvent) => { let ids = expand2.ids.slice(); const index = ids.indexOf(event.item.id); index === -1 ? ids.push(event.item.id) : ids.splice(index, 1); setExpand2({ ids, idField: 'id' }); }; const expandedData1 = React.useMemo(() => { return processOrgChartItems(tree, { expand: expand1, childrenField: 'employees' }); }, [expand1]); const expandedData2 = React.useMemo(() => { return processOrgChartItems(tree, { expand: expand2, childrenField: 'employees' }); }, [expand2]); return (