File tree Expand file tree Collapse file tree 5 files changed +37
-8
lines changed
apps/demos/Demos/Diagram/CustomShapesWithTemplates Expand file tree Collapse file tree 5 files changed +37
-8
lines changed Original file line number Diff line number Diff line change @@ -44,8 +44,13 @@ export class AppComponent {
4444 } ) ;
4545 }
4646
47- itemTypeExpr ( obj ) {
48- return `employee${ obj . ID } ` ;
47+ itemTypeExpr ( obj , value ) {
48+ if ( value ) {
49+ obj . type = value ;
50+ } else {
51+ return `employee${ obj . ID } ` ;
52+ }
53+ return null ;
4954 }
5055
5156 showInfo ( employee ) {
Original file line number Diff line number Diff line change @@ -11,8 +11,13 @@ const dataSource = new ArrayStore({
1111 data : employees ,
1212} ) ;
1313
14- function itemTypeExpr ( obj : { ID : number ; } ) {
15- return `employee${ obj . ID } ` ;
14+ function itemTypeExpr ( obj : { ID : number ; type : string ; } , value : string ) {
15+ if ( value ) {
16+ obj . type = value ;
17+ } else {
18+ return `employee${ obj . ID } ` ;
19+ }
20+ return null ;
1621}
1722
1823export default function App ( ) {
Original file line number Diff line number Diff line change @@ -10,8 +10,13 @@ const dataSource = new ArrayStore({
1010 key : 'ID' ,
1111 data : employees ,
1212} ) ;
13- function itemTypeExpr ( obj ) {
14- return `employee${ obj . ID } ` ;
13+ function itemTypeExpr ( obj , value ) {
14+ if ( value ) {
15+ obj . type = value ;
16+ } else {
17+ return `employee${ obj . ID } ` ;
18+ }
19+ return null ;
1520}
1621export default function App ( ) {
1722 const [ currentEmployee , setCurrentEmployee ] = useState ( { } ) ;
Original file line number Diff line number Diff line change @@ -67,7 +67,14 @@ const dataSource = new ArrayStore({
6767});
6868const currentEmployee = ref ({} as Record <string , any >);
6969const popupVisible = ref (false );
70- const itemTypeExpr = ({ ID }: any ) => ` employee${ID } ` ;
70+ const itemTypeExpr = (obj : { ID: number ; type: string ; }, value : string ) => {
71+ if (value ) {
72+ obj .type = value ;
73+ } else {
74+ return ` employee${obj .ID } ` ;
75+ }
76+ return null ;
77+ };
7178
7279function showInfo(employee : any ) {
7380 currentEmployee .value = employee ;
Original file line number Diff line number Diff line change @@ -29,7 +29,14 @@ $(() => {
2929 data : employees ,
3030 } ) ,
3131 keyExpr : 'ID' ,
32- typeExpr ( obj ) { return `employee${ obj . ID } ` ; } ,
32+ typeExpr ( obj , value ) {
33+ if ( value ) {
34+ obj . type = value ;
35+ } else {
36+ return `employee${ obj . ID } ` ;
37+ }
38+ return null ;
39+ } ,
3340 parentKeyExpr : 'Head_ID' ,
3441 autoLayout : {
3542 type : 'tree' ,
You can’t perform that action at this time.
0 commit comments