forked from syncfusion/ej2-javascript-ui-controls
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtreeview.ts
6675 lines (6344 loc) · 293 KB
/
treeview.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import { Component, EmitType, isUndefined, Browser, compile, isNullOrUndefined, SanitizeHtmlHelper, animationMode } from '@syncfusion/ej2-base';
import { Property, INotifyPropertyChanged, NotifyPropertyChanges, ChildProperty, Complex } from '@syncfusion/ej2-base';
import { Event, EventHandler, KeyboardEvents, KeyboardEventArgs } from '@syncfusion/ej2-base';
import { rippleEffect, Effect, Animation, AnimationOptions, RippleOptions, remove } from '@syncfusion/ej2-base';
import { Draggable, DragEventArgs, Droppable, DropEventArgs } from '@syncfusion/ej2-base';
import { getElement } from '@syncfusion/ej2-base';
import { addClass, removeClass, closest, matches, detach, select, selectAll, isVisible, append } from '@syncfusion/ej2-base';
import { DataManager, Query } from '@syncfusion/ej2-data';
import { isNullOrUndefined as isNOU, Touch, TapEventArgs, getValue, setValue, extend, merge, attributes } from '@syncfusion/ej2-base';
import { ListBase, ListBaseOptions, AriaAttributesMapping, FieldsMapping } from '@syncfusion/ej2-lists';
import { createCheckBox, rippleMouseHandler } from '@syncfusion/ej2-buttons';
import { Input, InputObject } from '@syncfusion/ej2-inputs';
import { createSpinner, showSpinner, hideSpinner } from '@syncfusion/ej2-popups';
import { TreeViewModel, FieldsSettingsModel, NodeAnimationSettingsModel, ActionSettingsModel } from './treeview-model';
const ROOT: string = 'e-treeview';
const CONTROL: string = 'e-control';
const COLLAPSIBLE: string = 'e-icon-collapsible';
const EXPANDABLE: string = 'e-icon-expandable';
const LISTITEM: string = 'e-list-item';
const LISTTEXT: string = 'e-list-text';
const LISTWRAP: string = 'e-text-wrap';
const IELISTWRAP: string = 'e-ie-wrap';
const PARENTITEM: string = 'e-list-parent';
const HOVER: string = 'e-hover';
const ACTIVE: string = 'e-active';
const LOAD: string = 'e-icons-spinner';
const PROCESS: string = 'e-process';
const ICON: string = 'e-icons';
const TEXTWRAP: string = 'e-text-content';
const INPUT: string = 'e-input';
const INPUTGROUP: string = 'e-input-group';
const TREEINPUT: string = 'e-tree-input';
const EDITING: string = 'e-editing';
const RTL: string = 'e-rtl';
const INTERACTION: string = 'e-interaction';
const DRAGITEM: string = 'e-drag-item';
const DROPPABLE: string = 'e-droppable';
const DRAGGING: string = 'e-dragging';
const SIBLING: string = 'e-sibling';
const DROPIN: string = 'e-drop-in';
const DROPNEXT: string = 'e-drop-next';
const DROPOUT: string = 'e-drop-out';
const NODROP: string = 'e-no-drop';
const FULLROWWRAP: string = 'e-fullrow-wrap';
const FULLROW: string = 'e-fullrow';
const SELECTED: string = 'e-selected';
const EXPANDED: string = 'e-expanded';
const NODECOLLAPSED: string = 'e-node-collapsed';
const DISABLE: string = 'e-disable';
const DROPCOUNT: string = 'e-drop-count';
const CHECK: string = 'e-check';
const INDETERMINATE: string = 'e-stop';
const CHECKBOXWRAP: string = 'e-treeview-checkbox';
const CHECKBOXFRAME: string = 'e-frame';
const CHECKBOXRIPPLE: string = 'e-ripple-container';
const RIPPLE: string = 'e-ripple';
const RIPPLEELMENT: string = 'e-ripple-element';
const FOCUS: string = 'e-node-focus';
const IMAGE: string = 'e-list-img';
const BIGGER: string = 'e-bigger';
const SMALL: string = 'e-small';
const CHILD: string = 'e-has-child';
const ITEM_ANIMATION_ACTIVE: string = 'e-animation-active';
const DISABLED: string = 'e-disabled';
const PREVENTSELECT: string = 'e-prevent';
const treeAriaAttr: TreeAriaAttr = {
treeRole: 'group',
itemRole: 'treeitem',
listRole: 'group',
itemText: '',
wrapperRole: ''
};
interface TreeAriaAttr extends AriaAttributesMapping {
treeRole: string;
wrapperRole: string;
}
interface ResultData {
result: { [key: string]: Object }[];
}
interface EJ2Instance extends HTMLElement {
// eslint-disable-next-line
ej2_instances: Object[];
}
/**
* Interface for NodeExpand event arguments.
*/
export interface NodeExpandEventArgs {
/**
* If you want to cancel this event then, set cancel as true. Otherwise, false.
*/
cancel: boolean;
/**
* If the event is triggered by interaction, it returns true. Otherwise, it returns false.
*/
isInteracted: boolean;
/**
* Return the expanded/collapsed TreeView node.
*/
node: HTMLLIElement;
/**
*
* Return the expanded/collapsed node as JSON object from data source.
*
*
*/
nodeData: { [key: string]: Object };
event: MouseEvent | KeyboardEventArgs | TapEventArgs;
}
/**
* Interface for NodeSelect event arguments.
*/
export interface NodeSelectEventArgs {
/**
* Return the name of action like select or un-select.
*/
action: string;
/**
* If you want to cancel this event then, set cancel as true. Otherwise, false.
*/
cancel: boolean;
/**
* If the event is triggered by interaction, it returns true. Otherwise, it returns false.
*/
isInteracted: boolean;
/**
* Return the currently selected TreeView node.
*/
node: HTMLLIElement;
/**
* Return the currently selected node as JSON object from data source.
*
*/
nodeData: { [key: string]: Object };
}
/**
* Interface for NodeCheck event arguments.
*/
export interface NodeCheckEventArgs {
/**
* Return the name of action like check or un-check.
*/
action: string;
/**
* If you want to cancel this event then, set cancel as true. Otherwise, false.
*/
cancel: boolean;
/**
* If the event is triggered by interaction, it returns true. Otherwise, it returns false.
*/
isInteracted: boolean;
/**
* Return the currently checked TreeView node.
*/
node: HTMLLIElement;
/**
* Return the currently checked node as JSON object from data source.
*
*/
data: { [key: string]: Object }[];
}
/**
* Interface for NodeEdit event arguments.
*/
export interface NodeEditEventArgs {
/**
* If you want to cancel this event then, set cancel as true. Otherwise, false.
*/
cancel: boolean;
/**
* Return the current TreeView node new text.
*/
newText: string;
/**
* Return the current TreeView node.
*/
node: HTMLLIElement;
/**
* Return the current node as JSON object from data source.
*
*/
nodeData: { [key: string]: Object };
/**
* Return the current TreeView node old text.
*/
oldText: string;
/**
* Gets or sets the inner HTML of TreeView node while editing.
*/
innerHtml: string;
}
/**
* Interface for DragAndDrop event arguments.
*/
export interface DragAndDropEventArgs {
/**
* If you want to cancel this event then, set cancel as true. Otherwise, false.
*/
cancel: boolean;
/**
* Return the cloned element
*/
clonedNode: HTMLElement;
/**
* Return the actual event.
*/
event: MouseEvent & TouchEvent;
/**
* Return the currently dragged TreeView node.
*/
draggedNode: HTMLLIElement;
/**
* Return the currently dragged node as array of JSON object from data source.
*
*/
draggedNodeData: { [key: string]: Object };
/**
* Returns the dragged/dropped element's target index position
*
*/
dropIndex: number;
/**
* Returns the dragged/dropped element's target level
*
*/
dropLevel: number;
/**
* Return the dragged element's source parent
*/
draggedParentNode: Element;
/**
* Return the dragged element's destination parent
*/
dropTarget: Element;
/**
* Return the cloned element's drop status icon while dragging
*/
dropIndicator: string;
/**
* Return the dropped TreeView node.
*/
droppedNode: HTMLLIElement;
/**
* Return the dropped node as array of JSON object from data source.
*
*/
droppedNodeData: { [key: string]: Object };
/**
* Return the target element from which drag starts/end.
*/
target: HTMLElement;
/**
* Return boolean value for preventing auto-expanding of parent node.
*/
preventTargetExpand?: boolean;
/**
* Denotes the cloned element's drop position relative to the dropped node while dragging. The available values are,
* 1. Inside – Denotes that the cloned element will be appended as the child node of the dropped node.
* 2. Before - Denotes that the cloned element will be appended before the dropped node.
* 3. After - Denotes that the cloned element will be appended after the dropped node.
*/
position: string;
}
/**
* Interface for DrawNode event arguments.
*/
export interface DrawNodeEventArgs {
/**
* Return the current rendering node.
*/
node: HTMLLIElement;
/**
* Return the current rendering node as JSON object.
*
* @isGenericType true
*/
nodeData: { [key: string]: Object };
/**
* Return the current rendering node text.
*/
text: string;
}
/**
* Interface for NodeClick event arguments.
*/
export interface NodeClickEventArgs {
/**
* Return the actual event.
*/
event: MouseEvent;
/**
* Return the current clicked TreeView node.
*/
node: HTMLLIElement;
}
/**
* Interface for NodeKeyPress event arguments.
*/
export interface NodeKeyPressEventArgs {
/**
* If you want to cancel this event then, set cancel as true. Otherwise, false.
*/
cancel: boolean;
/**
* Return the actual event.
*
*/
event: KeyboardEventArgs;
/**
* Return the current active TreeView node.
*/
node: HTMLLIElement;
}
/**
* Interface for DataBound event arguments.
*/
export interface DataBoundEventArgs {
/**
* Return the TreeView data.
*
* @isGenericType true
*/
data: { [key: string]: Object }[];
}
/**
* Interface for DataSourceChanged event arguments.
*/
export interface DataSourceChangedEventArgs {
/**
* Return the updated TreeView data. The data source will be updated after performing some operation like
* drag and drop, node editing, adding and removing node. If you want to get updated data source after performing operation like
* selecting/unSelecting, checking/unChecking, expanding/collapsing the node, then you can use getTreeData method.
*
* @isGenericType true
*/
data: { [key: string]: Object }[];
/**
* Return the action which triggers the event
*
*/
action: string;
/**
* Return the new node data of updated data source
*
*/
nodeData: { [key: string]: Object }[];
}
interface ItemCreatedArgs {
curData: { [key: string]: Object };
item: HTMLElement;
options: ListBaseOptions;
text: string;
fields: FieldsMapping;
}
/**
* Interface that holds the node details.
*/
export interface NodeData {
/**
* Specifies the ID field mapped in dataSource.
*/
id: string;
/**
* Specifies the mapping field for text displayed as TreeView node's display text.
*/
text: string;
/**
* Specifies the parent ID field mapped in dataSource.
*/
parentID: string;
/**
* Specifies the mapping field for selected state of the TreeView node.
*/
selected: boolean;
/**
* Specifies the mapping field for expand state of the TreeView node.
*/
expanded: boolean;
/**
* Specifies the field for checked state of the TreeView node.
*/
isChecked: string;
/**
* Specifies the mapping field for hasChildren to check whether a node has child nodes or not.
*/
hasChildren: boolean;
}
/**
* Interface for Failure event arguments
*/
export interface FailureEventArgs {
/** Defines the error information. */
error?: Error;
}
/**
* Configures the fields to bind to the properties of node in the TreeView component.
*/
export class FieldsSettings extends ChildProperty<FieldsSettings> {
/**
* Binds the field settings for child nodes or mapping field for nested nodes objects that contain array of JSON objects.
*/
@Property('child')
public child: string | FieldsSettingsModel;
/**
* Specifies the array of JavaScript objects or instance of DataManager to populate the nodes.
*
* @default []
* @aspDatasourceNullIgnore
* @isGenericType true
*/
@Property([])
public dataSource: DataManager | { [key: string]: Object }[];
/**
* Specifies the mapping field for expand state of the TreeView node.
*/
@Property('expanded')
public expanded: string;
/**
* Specifies the mapping field for hasChildren to check whether a node has child nodes or not.
*/
@Property('hasChildren')
public hasChildren: string;
/**
* Specifies the mapping field for htmlAttributes to be added to the TreeView node.
*/
@Property('htmlAttributes')
public htmlAttributes: string;
/**
* Specifies the mapping field for icon class of each TreeView node that will be added before the text.
*/
@Property('iconCss')
public iconCss: string;
/**
* Specifies the ID field mapped in dataSource.
*/
@Property('id')
public id: string;
/**
* Specifies the mapping field for image URL of each TreeView node where image will be added before the text.
*/
@Property('imageUrl')
public imageUrl: string;
/**
* Specifies the field for checked state of the TreeView node.
*/
@Property('isChecked')
public isChecked: string;
/**
* Specifies the parent ID field mapped in dataSource.
*/
@Property('parentID')
public parentID: string;
/**
* Defines the external [`Query`](https://ej2.syncfusion.com/documentation/api/data/query/)
* that will execute along with data processing.
*
* @default null
*/
@Property(null)
public query: Query;
/**
* Specifies whether the node can be selected by users or not
* When set to false, the user interaction is prevented for the corresponding node.
*/
@Property('selectable')
public selectable: string;
/**
* Specifies the mapping field for selected state of the TreeView node.
*/
@Property('selected')
public selected: string;
/**
* Specifies the table name used to fetch data from a specific table in the server.
*/
@Property(null)
public tableName: string;
/**
* Specifies the mapping field for text displayed as TreeView node's display text.
*/
@Property('text')
public text: string;
/**
* Specifies the mapping field for tooltip that will be displayed as hovering text of the TreeView node.
*/
@Property('tooltip')
public tooltip: string;
/**
* Specifies the mapping field for navigateUrl to be added as hyper-link of the TreeView node.
*/
@Property('navigateUrl')
public navigateUrl: string;
}
/**
* Defines the expand type of the TreeView node.
* ```props
* Auto :- The expand/collapse operation happens when you double-click on the node in desktop.
* Click :- The expand/collapse operation happens when you single-click on the node in desktop.
* DblClick :- The expand/collapse operation happens when you double-click on the node in desktop.
* None :- The expand/collapse operation will not happen.
* ```
*/
export type ExpandOnSettings = 'Auto' | 'Click' | 'DblClick' | 'None';
/**
* Defines the sorting order type for TreeView.
* ```props
* None :- Indicates that the nodes are not sorted.
* Ascending :- Indicates that the nodes are sorted in the ascending order.
* Descending :- Indicates that the nodes are sorted in the descending order
* ```
*/
export type SortOrder = 'None' | 'Ascending' | 'Descending';
/**
* Configures animation settings for the TreeView component.
*/
export class ActionSettings extends ChildProperty<ActionSettings> {
/**
* Specifies the type of animation.
*
* @default 'SlideDown'
*/
@Property('SlideDown')
public effect: Effect;
/**
* Specifies the duration to animate.
*
* @default 400
*/
@Property(400)
public duration: number;
/**
* Specifies the animation timing function.
*
* @default 'linear'
*/
@Property('linear')
public easing: string;
}
/**
* Configures the animation settings for expanding and collapsing nodes in TreeView.
*/
export class NodeAnimationSettings extends ChildProperty<NodeAnimationSettings> {
/**
* Specifies the animation that applies on collapsing the nodes.
*
* @default { effect: 'SlideUp', duration: 400, easing: 'linear' }
*/
@Complex<ActionSettingsModel>({ effect: 'SlideUp', duration: 400, easing: 'linear' }, ActionSettings)
public collapse: ActionSettingsModel;
/**
* Specifies the animation that applies on expanding the nodes.
*
* @default { effect: 'SlideDown', duration: 400, easing: 'linear' }
*/
@Complex<ActionSettingsModel>({ effect: 'SlideDown', duration: 400, easing: 'linear' }, ActionSettings)
public expand: ActionSettingsModel;
}
/**
* The TreeView component is used to represent hierarchical data in a tree like structure with advanced
* functions to perform edit, drag and drop, selection with check-box, and more.
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView();
* treeObj.appendTo('#tree');
* ```
*/
@NotifyPropertyChanges
export class TreeView extends Component<HTMLElement> implements INotifyPropertyChanged {
/* Internal variables */
private initialRender: boolean;
private treeData: { [key: string]: Object }[];
private rootData: { [key: string]: Object }[];
private groupedData: { [key: string]: Object }[][];
private ulElement: HTMLElement;
private listBaseOption: ListBaseOptions;
private dataType: number;
private rippleFn: Function;
private rippleIconFn: Function;
private isNumberTypeId: boolean;
private expandOnType: string;
private keyboardModule: KeyboardEvents;
private liList: HTMLElement[];
private aniObj: Animation;
private treeList: string[];
private isLoaded: boolean;
private expandArgs: NodeExpandEventArgs;
private oldText: string;
private dragObj: Draggable;
private dropObj: Droppable;
private dragTarget: Element;
private dragLi: Element;
private dragData: { [key: string]: Object };
private startNode: Element;
private nodeTemplateFn: Function;
private currentLoadData: { [key: string]: Object }[];
private checkActionNodes: { [key: string]: Object }[];
private touchEditObj: Touch;
private touchClickObj: Touch;
private dragStartAction: boolean;
private touchExpandObj: Touch;
private inputObj: InputObject;
private isAnimate: boolean;
private touchClass: string;
private editData: { [key: string]: Object };
private editFields: FieldsSettingsModel;
private refreshData: { [key: string]: Object };
private isRefreshed: boolean = false;
private keyConfigs: { [key: string]: string };
private isInitalExpand: boolean;
private index: number;
private preventExpand: boolean = false;
private hasPid: boolean;
private dragParent: Element;
private checkedElement: string[] = [];
private ele: number;
private disableNode: string[] = [];
private onLoaded: boolean;
private parentNodeCheck: string[];
private parentCheckData: { [key: string]: Object }[];
private validArr: { [key: string]: Object }[] = [];
private validNodes: string[] = [];
private expandChildren: string[] = [];
private isFieldChange: boolean = false;
private changeDataSource: boolean = false;
private isOffline: boolean;
private firstTap: Element;
private hasTemplate: boolean = false;
private isFirstRender: boolean = false;
// Specifies whether the node is dropped or not
private isNodeDropped: boolean = false;
private isInteracted: boolean = false;
private isRightClick: boolean = false;
private mouseDownStatus: boolean = false;
private isDropIn: boolean = false;
private DDTTreeData: { [key: string]: Object }[];
private OldCheckedData: { [key: string]: Object; }[] = [];
private isHiddenItem: boolean = false;
/**
* Indicates whether the TreeView allows drag and drop of nodes. To drag and drop a node in
* desktop, hold the mouse on the node, drag it to the target node and drop the node by releasing
* the mouse. For touch devices, drag and drop operation is performed by touch, touch move
* and touch end. For more information on drag and drop nodes concept, refer to
* [Drag and Drop](../../treeview/drag-and-drop/).
*
* @default false
*/
@Property(false)
public allowDragAndDrop: boolean;
/**
* Enables or disables editing of the text in the TreeView node. When `allowEditing` property is set
* to true, the TreeView allows you to edit the node by double clicking the node or by navigating to
* the node and pressing **F2** key. For more information on node editing, refer
* to [Node Editing](../../treeview/node-editing/).
*
* @default false
*/
@Property(false)
public allowEditing: boolean;
/**
* Enables or disables multi-selection of nodes. To select multiple nodes:
* * Select the nodes by holding down the **Ctrl** key while clicking on the nodes.
* * Select consecutive nodes by clicking the first node to select and hold down the **Shift** key
* and click the last node to select.
*
* For more information on multi-selection, refer to
* [Multi-Selection](../../treeview/multiple-selection/).
*
* @default false
*/
@Property(false)
public allowMultiSelection: boolean;
/**
* Enables or disables text wrapping when text exceeds the bounds in the TreeView node.
* When the allowTextWrap property is set to true, the TreeView node text content will wrap to the next line
* when it exceeds the width of the TreeView node.
* The TreeView node height will be adjusted automatically based on the TreeView node content.
*
* @default false
*/
@Property(false)
public allowTextWrap: boolean;
/**
* Specifies the type of animation applied on expanding and collapsing the nodes along with duration.
*
* @default {expand: { effect: 'SlideDown', duration: 400, easing: 'linear' },
* collapse: { effect: 'SlideUp', duration: 400, easing: 'linear' }}
*/
@Complex<NodeAnimationSettingsModel>({}, NodeAnimationSettings)
public animation: NodeAnimationSettingsModel;
/**
* The `checkedNodes` property is used to set the nodes that need to be checked.
* This property returns the checked nodes ID in the TreeView component.
* The `checkedNodes` property depends upon the value of `showCheckBox` property.
* For more information on checkedNodes, refer to
* [checkedNodes](../../treeview/check-box#checked-nodes).
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* showCheckBox: true,
* checkedNodes: ['01-01','02']
* });
* treeObj.appendTo('#tree');
* ```
*
* @default []
*/
@Property()
public checkedNodes: string[];
/**
* Determines whether the disabled children will be checked or not if their parent is checked.
*
* @default true
*/
@Property(true)
public checkDisabledChildren: boolean;
/**
* Specifies one or more than one CSS classes to be added with root element of the TreeView to help customize the appearance of the component.
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* cssClass: 'e-custom e-tree'
* });
* treeObj.appendTo('#tree');
* ```
* ```css
* .e-custom .e-tree {
* max-width: 600px;
* }
* .e-custom .e-list-item {
* padding: 10px 0;
* }
* ```
*
* @default ''
*/
@Property('')
public cssClass: string;
/**
* Specifies a value that indicates whether the TreeView component is disabled or not.
* When set to true, user interaction will not be occurred in TreeView.
*
* @default false
*/
@Property(false)
public disabled: boolean;
/**
* Specifies the target in which the draggable element can be moved and dropped.
* By default, the draggable element movement occurs in the page.
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* dragArea: '.control_wrapper'
* });
* treeObj.appendTo('#tree');
* ```
* ```css
* .control_wrapper {
* width: 500px;
* margin-left: 100px;
* }
* ```
*
* @default null
*/
@Property(null)
public dragArea: HTMLElement | string;
/**
* Specifies whether to display or remove the untrusted HTML values in the TreeView component.
* If 'enableHtmlSanitizer' set to true, the component will sanitize any suspected untrusted strings and scripts before rendering them.
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* enableHtmlSanitizer: true
* });
* treeObj.appendTo('#tree');
* ```
*
* @default true
*/
@Property(true)
public enableHtmlSanitizer: boolean;
/**
* Enables or disables persisting TreeView state between page reloads. If enabled, following APIs will persist.
* 1. `selectedNodes` - Represents the nodes that are selected in the TreeView component.
* 2. `checkedNodes` - Represents the nodes that are checked in the TreeView component.
* 3. `expandedNodes` - Represents the nodes that are expanded in the TreeView component.
*
* @default false
*/
@Property(false)
public enablePersistence: boolean;
/**
* Represents the expanded nodes in the TreeView component. We can set the nodes that need to be
* expanded or get the ID of the nodes that are currently expanded by using this property.
* ```html
* <div id='tree'></div>
* ```
* ```typescript
* <script>
* var treeObj = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* expandedNodes: ['01','01-01','02']
* });
* treeObj.appendTo('#tree');
* </script>
* ```
*
* @default []
*/
@Property()
public expandedNodes: string[];
/**
* Specifies the action on which the node expands or collapses.
* The available actions :
* `Click` - The expand/collapse operation happens when you single-click on the node in desktop.
* `DblClick` - The expand/collapse operation happens when you double-click on the node in desktop.
* `None` - The expand/collapse operation will not happen.
* In mobile devices, the node expand/collapse action happens on single tap.
* Here ExpandOn attribute is set to single click property also can use double click and none property.
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* expandOn: 'Click'
* });
* treeObj.appendTo('#tree');
* ```
*
* @default 'Auto'
*/
@Property('Auto')
public expandOn: ExpandOnSettings;
/**
* Specifies the data source and mapping fields to render TreeView nodes.
*
* @default {id: 'id', text: 'text', dataSource: [], child: 'child', parentID: 'parentID', hasChildren: 'hasChildren',
* expanded: 'expanded', htmlAttributes: 'htmlAttributes', iconCss: 'iconCss', imageUrl: 'imageUrl', isChecked: 'isChecked',
* query: null, selected: 'selected', tableName: null, tooltip: 'tooltip', navigateUrl: 'navigateUrl'}
*/
@Complex<FieldsSettingsModel>({}, FieldsSettings)
public fields: FieldsSettingsModel;
/**
* On enabling this property, the entire row of the TreeView node gets selected by clicking a node.
* When disabled only the corresponding node's text gets selected.
* For more information on Fields concept, refer to
* [Fields](../../treeview/data-binding#local-data).
*
* @default true
*/
@Property(true)
public fullRowSelect: boolean;
/**
* By default, the load on demand (Lazy load) is set to true. By disabling this property, all the tree nodes are rendered at the
* beginning itself.
*
* @default true
*/
@Property(true)
public loadOnDemand: boolean;
/**
* Overrides the global culture and localization value for this component. Default global culture is 'en-US'.
*
* @private
*/
@Property()
public locale: string;
/**
* Specifies a template to render customized content for all the nodes. If the `nodeTemplate` property
* is set, the template content overrides the displayed node text. The property accepts template string
* [template string](https://ej2.syncfusion.com/documentation/common/template-engine/)
* or HTML element ID holding the content. For more information on template concept, refer to
* [Template](../../treeview/template/).
*
* @default null
* @angularType string | object
* @reactType string | function | JSX.Element
* @vueType string | function
* @aspType string
*/
@Property()
public nodeTemplate: string | Function;
/**
* Represents the selected nodes in the TreeView component. We can set the nodes that need to be
* selected or get the ID of the nodes that are currently selected by using this property.
* On enabling `allowMultiSelection` property we can select multiple nodes and on disabling
* it we can select only a single node.
* For more information on selectedNodes, refer to
* [selectedNodes](../../treeview/multiple-selection#selected-nodes).
* ```html
* <div id="tree"></div>
* ```
* ```typescript
* let treeObj: TreeView = new TreeView({
* fields: { dataSource: hierarchicalData, id: 'id', text: 'name', child: 'subChild' },
* allowMultiSelection: true,
* selectedNodes: ['01','02']
* });
* treeObj.appendTo('#tree');
* ```
*
* @default []
*/
@Property()
public selectedNodes: string[];
/**
* Specifies a value that indicates whether the nodes are sorted in the ascending or descending order,
* or are not sorted at all. The available types of sort order are,
* * `None` - The nodes are not sorted.
* * `Ascending` - The nodes are sorted in the ascending order.
* * `Descending` - The nodes are sorted in the ascending order.
*
* @default 'None'
*/
@Property('None')
public sortOrder: SortOrder;
/**
* Indicates that the nodes will display CheckBoxes in the TreeView.
* The CheckBox will be displayed next to the expand/collapse icon of the node. For more information on CheckBoxes, refer to
* [CheckBox](../../treeview/check-box/).