selectitemeditfield_wev8.js
7.24 KB
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
Ext.namespace("Ext.ux.form");
var triggerObj;
Ext.ux.form.SelectitemEditField=Ext.extend(Ext.form.TriggerField,{
defaultAutoCreate:{
tag:"input",type:"text",size:"16",style:"cursor:default;",autocomplete:"off"
}
,triggerClass:"x-form-editor-trigger",validateOnBlur:false,multiSelect:false,showOnFocus:false,sFeatures : "dialogHeight:500px;dialogWidth:800px;status:no;center:yes;resizable:yes",url:"blank",initComponent:function(){
Ext.ux.form.SelectitemEditField.superclass.initComponent.call(this);
if(this.store){
if(!this.valueField){
this.valueField="value"
}
if(!this.displayField){
this.displayField="text"
}
}
}
,onRender:function(b,a){
if(this.isRendered){
return
}
this.readOnly=true;
if(this.textarea){
this.defaultAutoCreate={
tag:"textarea",style:"cursor:default;width:124px;height:65px;",autocomplete:"off"
};
this.displaySeparator="\n"
}
Ext.ux.form.SelectitemEditField.superclass.onRender.call(this,b,a);
if(this.hiddenName){
this.hiddenField=this.el.insertSibling({
tag:"input",type:"hidden",name:this.hiddenName,id:(this.hiddenId||this.hiddenName)
}
,"before",true);
this.hiddenField.value=this.hiddenValue!==undefined?this.hiddenValue:this.value!==undefined?this.value:"";
this.el.dom.removeAttribute("name")
}
this.el.dom.removeAttribute("name");
if(this.showOnFocus){
this.on("focus",this.onTriggerClick,this)
}
this.isRendered=true
}
,onSelect:function(f){
if(f){
Ext.form.ComboBox.superclass.setValue.call(this,f[1]);
this.value=f[0];
if(this.hiddenField){
this.hiddenField.setAttribute("value",f[0])
}
}
if(Ext.QuickTips){
Ext.QuickTips.enable()
}
}
,getValue:function(){
return Ext.form.ComboBox.superclass.getValue.call(this);
}
,setValue:function(a){
var c=a;
this.lastSelectionText=c;
if(this.hiddenField){
this.hiddenField.value=a
}
Ext.form.ComboBox.superclass.setValue.call(this,c);
this.value=a
}
,findRecord:function(c,b){
var a;
if(this.store.getCount()>0){
this.store.each(function(d){
if(d.data[c]==b){
a=d;
return false
}
})
}
return a
}
,onTriggerClick:function(a){
triggerObj = Ext.getCmp(this.id);
var theEditGrid = this.editgrid;
theEditGrid.stopEditing();
var theRowIndex = this.rowIndex;
var theStoreRecord = this.storeRecord;
var theFormtablename = this.formtablename;
if(jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex).length == 0){
var $obj = jQuery("<div id=\"SeleteItem_"+theFormtablename+"_"+theRowIndex+"\"></div>");
var html = "<div id=\"div5_"+theRowIndex+"\" style=\"vertical-align: middle; height:30px; line-height: 30px;text-align: left;padding-left: 5px;\">"
+ "<button type=\"button\" class=\"addbtn\" id=\"btnaddRow\" name=\"btnaddRow\" onclick=\"addoTableRow("+theRowIndex+")\" title=\"添加内容\" style=\"margin-bottom:-5px;\"></BUTTON>"
+ "<button type=\"button\" class=\"delbtn\" id=\"btnsubmitClear\" name=\"btnsubmitClear\" onclick=\"submitClear("+theRowIndex+")\" title=\"删除内容\" style=\"margin-bottom:-5px;\"></BUTTON>"
+ "<span>关联子字段 </span>"
+ "<button type=\"button\" id=\"showChildFieldBotton\" class=\"Browser\" onClick=\"onShowChildField('childfieldidSpan_"+theRowIndex+"','childfieldid_"+theRowIndex+"','_"+theRowIndex+"')\"></BUTTON>"
+ "<span id=\"childfieldidSpan_"+theRowIndex+"\"></span>"
+ "<input type=\"hidden\" value=\"\" name=\"childfieldid_"+theRowIndex+"\" id=\"childfieldid_"+theRowIndex+"\">"
+ "</div>";
html += "<div id=\"div5_5_"+theRowIndex+"\">"
+ "<table class=\"liststyle\" id=\"choiceTable_"+theRowIndex+"\" cols=\"6\" border=\"0\" style=\"width: 100%;\" cellspacing=\"collapse\">"
+ "<COL width=\"5%\">"
+ "<COL width=\"25%\">"
+ "<COL width=\"5%\">"
+ "<COL width=\"10%\">"
+ "<COL width=\"33%\">"
+ "<COL width=\"22%\">"
+ "<tr>"
+ "<td>选中</td>"
+ "<td style='text-align: left;padding-left:15px;'>可选项文字</td>"
+ "<td>排序</td>"
+ "<td>默认值</td>"
+ "<td>关联文档目录</td>"
+ "<td>子字段选项</td>"
+ "</tr>"
+ "<input type=\"hidden\" value=\"0\" name=\"choiceRows_"+theRowIndex+"\" id=\"choiceRows_"+theRowIndex+"\">"
+ "</table>"
+ "</div>";
$obj.append(html);
jQuery("#SeleteItem_ALL").append($obj);
}
var valueIsChange = false;
function changeValueFlag(){
valueIsChange = true;
}
var diag = new Dialog({
ID: "SeleteItemDialog_" + theRowIndex,
Width: 550,
Height: 300,
Modal: true,
ShowButtonRow:true
});
diag.CancelEvent = function () {
setSelectValue();
};
diag.OKEvent = function () {
setSelectValue();
};
function setSelectValue(){
var selitems = $("#choiceTable_"+theRowIndex).find(".selectitemname");
for(var i=0;i<selitems.length;i++){
var obj = selitems.get(i);
if(obj.value==''){
Dialog.alert(SystemEnv.getHtmlNoteName(3606,readCookie("languageidweaver")));
return;
}
}
jQuery("#SeleteItem_ALL").append(jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex));
diag.close();
/*
var selectitemDisplayText = new Date().toLocaleTimeString();
triggerObj.onSelect([selectitemDisplayText, selectitemDisplayText]);
*/
var selectitemDisplayText = "";
jQuery("tr:gt(0)", "#choiceTable_" + theRowIndex).each(function(){
var sv = jQuery("td:eq(1) input[type='text']", jQuery(this)).val();
if(sv != ""){
selectitemDisplayText += sv + ",";
}
});
if(selectitemDisplayText != ""){
selectitemDisplayText = selectitemDisplayText.substring(0, selectitemDisplayText.length - 1);
}
if(valueIsChange){ //加个空格,强制让record的fieldtype处于被修改过的状态
selectitemDisplayText += " ";
}
theStoreRecord.set('fieldtype',selectitemDisplayText);
jQuery("input", jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex)).unbind("click", changeValueFlag);
jQuery("button.Browser", jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex)).unbind("click", changeValueFlag);
}
diag.Title = SystemEnv.getHtmlNoteName(3557,readCookie("languageidweaver"));
diag.InnerHtml = "<div id='SeleteItemContainer_"+theRowIndex+"'></div>";
//diag.InnerHtml = jQuery("#SeleteItem_45")[0].outerHTML;
diag.show();
jQuery("#SeleteItemContainer_" + theRowIndex).append(jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex));
var dialogDiv = diag.getDialogDiv();
dialogDiv.style.zIndex = 99999;
jQuery("#_Container_SeleteItemDialog_" + theRowIndex).css("overflow","auto");
jQuery("input", jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex)).bind("click", changeValueFlag);
jQuery("button.Browser", jQuery("#SeleteItem_" + theFormtablename + "_" + theRowIndex)).bind("click", changeValueFlag);
$("#_ButtonCancel_SeleteItemDialog_"+theRowIndex).hide();//hide cancel button
return;
}
});
Ext.reg("xselectitemeditfield",Ext.ux.form.SelectitemEditField);