cy
2022-06-21 129904537f66509f97b285e7eb4f42b3dc349dd0
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
/**
 * jQuery EasyUI 1.3.5
 * 
 * Copyright (c) 2009-2013 www.jeasyui.com. All rights reserved.
 *
 * Licensed under the GPL or commercial licenses
 * To use it on other terms please contact us: info@jeasyui.com
 * http://www.gnu.org/licenses/gpl.txt
 * http://www.jeasyui.com/license_commercial.php
 *
 */
(function($){
function _1(_2){
var _3=$.data(_2,"combogrid");
var _4=_3.options;
var _5=_3.grid;
$(_2).addClass("combogrid-f").combo(_4);
var _6=$(_2).combo("panel");
if(!_5){
_5=$("<table></table>").appendTo(_6);
_3.grid=_5;
}
_5.datagrid($.extend({},_4,{border:false,fit:true,singleSelect:(!_4.multiple),onLoadSuccess:function(_7){
var _8=$(_2).combo("getValues");
var _9=_4.onSelect;
_4.onSelect=function(){
};
_1a(_2,_8,_3.remainText);
_4.onSelect=_9;
_4.onLoadSuccess.apply(_2,arguments);
},onClickRow:_a,onSelect:function(_b,_c){
_d();
_4.onSelect.call(this,_b,_c);
},onUnselect:function(_e,_f){
_d();
_4.onUnselect.call(this,_e,_f);
},onSelectAll:function(_10){
_d();
_4.onSelectAll.call(this,_10);
},onUnselectAll:function(_11){
if(_4.multiple){
_d();
}
_4.onUnselectAll.call(this,_11);
}}));
function _a(_12,row){
_3.remainText=false;
_d();
if(!_4.multiple){
$(_2).combo("hidePanel");
}
_4.onClickRow.call(this,_12,row);
};
function _d(){
var _13=_5.datagrid("getSelections");
var vv=[],ss=[];
for(var i=0;i<_13.length;i++){
vv.push(_13[i][_4.idField]);
ss.push(_13[i][_4.textField]);
}
if(!_4.multiple){
$(_2).combo("setValues",(vv.length?vv:[""]));
}else{
$(_2).combo("setValues",vv);
}
if(!_3.remainText){
$(_2).combo("setText",ss.join(_4.separator));
}
};
};
function nav(_14,dir){
var _15=$.data(_14,"combogrid");
var _16=_15.options;
var _17=_15.grid;
var _18=_17.datagrid("getRows").length;
if(!_18){
return;
}
var tr=_16.finder.getTr(_17[0],null,"highlight");
if(!tr.length){
tr=_16.finder.getTr(_17[0],null,"selected");
}
var _19;
if(!tr.length){
_19=(dir=="next"?0:_18-1);
}else{
var _19=parseInt(tr.attr("datagrid-row-index"));
_19+=(dir=="next"?1:-1);
if(_19<0){
_19=_18-1;
}
if(_19>=_18){
_19=0;
}
}
_17.datagrid("highlightRow",_19);
if(_16.selectOnNavigation){
_15.remainText=false;
_17.datagrid("selectRow",_19);
}
};
function _1a(_1b,_1c,_1d){
var _1e=$.data(_1b,"combogrid");
var _1f=_1e.options;
var _20=_1e.grid;
var _21=_20.datagrid("getRows");
var ss=[];
var _22=$(_1b).combo("getValues");
var _23=$(_1b).combo("options");
var _24=_23.onChange;
_23.onChange=function(){
};
_20.datagrid("clearSelections");
for(var i=0;i<_1c.length;i++){
var _25=_20.datagrid("getRowIndex",_1c[i]);
if(_25>=0){
_20.datagrid("selectRow",_25);
ss.push(_21[_25][_1f.textField]);
}else{
ss.push(_1c[i]);
}
}
$(_1b).combo("setValues",_22);
_23.onChange=_24;
$(_1b).combo("setValues",_1c);
if(!_1d){
var s=ss.join(_1f.separator);
if($(_1b).combo("getText")!=s){
$(_1b).combo("setText",s);
}
}
};
function _26(_27,q){
var _28=$.data(_27,"combogrid");
var _29=_28.options;
var _2a=_28.grid;
_28.remainText=true;
if(_29.multiple&&!q){
_1a(_27,[],true);
}else{
_1a(_27,[q],true);
}
if(_29.mode=="remote"){
_2a.datagrid("clearSelections");
_2a.datagrid("load",$.extend({},_29.queryParams,{q:q}));
}else{
if(!q){
return;
}
var _2b=_2a.datagrid("getRows");
for(var i=0;i<_2b.length;i++){
if(_29.filter.call(_27,q,_2b[i])){
_2a.datagrid("clearSelections");
_2a.datagrid("selectRow",i);
return;
}
}
}
};
function _2c(_2d){
var _2e=$.data(_2d,"combogrid");
var _2f=_2e.options;
var _30=_2e.grid;
var tr=_2f.finder.getTr(_30[0],null,"highlight");
if(!tr.length){
tr=_2f.finder.getTr(_30[0],null,"selected");
}
if(!tr.length){
return;
}
_2e.remainText=false;
var _31=parseInt(tr.attr("datagrid-row-index"));
if(_2f.multiple){
if(tr.hasClass("datagrid-row-selected")){
_30.datagrid("unselectRow",_31);
}else{
_30.datagrid("selectRow",_31);
}
}else{
_30.datagrid("selectRow",_31);
$(_2d).combogrid("hidePanel");
}
};
$.fn.combogrid=function(_32,_33){
if(typeof _32=="string"){
var _34=$.fn.combogrid.methods[_32];
if(_34){
return _34(this,_33);
}else{
return this.combo(_32,_33);
}
}
_32=_32||{};
return this.each(function(){
var _35=$.data(this,"combogrid");
if(_35){
$.extend(_35.options,_32);
}else{
_35=$.data(this,"combogrid",{options:$.extend({},$.fn.combogrid.defaults,$.fn.combogrid.parseOptions(this),_32)});
}
_1(this);
});
};
$.fn.combogrid.methods={options:function(jq){
var _36=jq.combo("options");
return $.extend($.data(jq[0],"combogrid").options,{originalValue:_36.originalValue,disabled:_36.disabled,readonly:_36.readonly});
},grid:function(jq){
return $.data(jq[0],"combogrid").grid;
},setValues:function(jq,_37){
return jq.each(function(){
_1a(this,_37);
});
},setValue:function(jq,_38){
return jq.each(function(){
_1a(this,[_38]);
});
},clear:function(jq){
return jq.each(function(){
$(this).combogrid("grid").datagrid("clearSelections");
$(this).combo("clear");
});
},reset:function(jq){
return jq.each(function(){
var _39=$(this).combogrid("options");
if(_39.multiple){
$(this).combogrid("setValues",_39.originalValue);
}else{
$(this).combogrid("setValue",_39.originalValue);
}
});
}};
$.fn.combogrid.parseOptions=function(_3a){
var t=$(_3a);
return $.extend({},$.fn.combo.parseOptions(_3a),$.fn.datagrid.parseOptions(_3a),$.parser.parseOptions(_3a,["idField","textField","mode"]));
};
$.fn.combogrid.defaults=$.extend({},$.fn.combo.defaults,$.fn.datagrid.defaults,{loadMsg:null,idField:null,textField:null,mode:"local",keyHandler:{up:function(e){
nav(this,"prev");
e.preventDefault();
},down:function(e){
nav(this,"next");
e.preventDefault();
},left:function(e){
},right:function(e){
},enter:function(e){
_2c(this);
},query:function(q,e){
_26(this,q);
}},filter:function(q,row){
var _3b=$(this).combogrid("options");
return row[_3b.textField].indexOf(q)==0;
}});
})(jQuery);