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
| /**
| @name Edo.controls.TreeSelect
| @class
| @typeName TreeSelect
| @description 树形选框下拉框
| @extend Edo.controls.Trigger
| @example
| */
| Edo.controls.TreeSelect = function(){
|
| Edo.controls.TreeSelect.superclass.constructor.call(this);
| };
| Edo.controls.TreeSelect.extend(Edo.controls.Trigger,{
| treeConfig: null,
|
| data: null,
|
| multiSelect: true,
| popupMinWidth: 150,
|
| enableResizePopup: true,
|
| popupHeight: 150,
|
| valueField: 'id',
| displayText: '名称',
| displayField: 'text',
| valueField: 'text',
| delimiter: ',',
|
| autoExpandColumn: 'display',
|
| triggerPopup: true,
| readOnly: true,
|
| // _setValue: function(values){
| // this.tree.setValue(vs);
| // },
| setValue: function(vv){
| this.tree.setValue(vv);
| },
| getValue: function(){
| return this.tree.getValue();
| },
|
| viewText: function(){
| var texts = [];
|
| var selecteds = this.tree.getSelecteds();
| selecteds.each(function(o){
| texts.add(o[this.displayField]);
| }, this);
| this._setText(texts.join(this.delimiter));
| },
|
| _setData: function(data){
| if(typeof data === 'string') data = window[data];
| if(!data) return;
| if(!data.dataTable) data = new Edo.data.DataTree(data || []);
|
| this.data = data;
|
| if(this.tree) this.tree.set('data', data);
|
| this.changeProperty('data', data);
| },
|
| onselectionchange: function(e){
| this.selectionchanged = true;
| this.viewText();
| this.changeProperty('value', this.getValue(), true);
| },
| init: function(){
| Edo.controls.TreeSelect.superclass.init.a(this, arguments);
|
| if(!this.tree){
| this.tree = Edo.create(Edo.apply({
| type: 'tree',
| style: 'border:0',
| width: '100%',
| height: '100%',
| //autoHeight: true,
| minHeight: 80,
| maxHeight: 250,
| treeColumn: 'display',
| multiSelect: this.multiSelect,
| rowSelectMode: this.multiSelect ? 'multi' : 'single',
| autoExpandColumn: this.autoExpandColumn,
| valueField: this.valueField,
| columns: [
| Edo.lists.Table.createMultiColumn(),
| {id: 'display', width: '100%', header: this.displayText, dataIndex: this.displayField}
| ],
| delimiter: this.delimiter,
| onselectionchange: this.onselectionchange.bind(this)
| }, this.treeConfig));
| }
| this.tree.set('data', this.data);
| },
| showPopup: function(){
| Edo.controls.TreeSelect.superclass.showPopup.a(this, arguments);
|
| if(!this.tree.parent){
| this.popupCt.addChild(this.tree);
| }
| var sels = this.tree.getSelecteds().clone();
| this.tree.set('data', this.data);
| this.tree.selectRange(sels);
| },
| hidePopup: function(){
| Edo.controls.TreeSelect.superclass.hidePopup.a(this, arguments);
|
| if(this.selectionchanged){
| this.fireEvent('selectionchange', {
| type: 'selectionchange',
| source: this
| });
| }
| this.selectionchanged = false;
| }
| });
|
| Edo.controls.TreeSelect.regType('TreeSelect');
|
|