Просмотр исходного кода

Merge branch 'fix/datagrid_textarea_show' into 'release'

修复数据网格中多行文本换行显示问题

See merge request o2oa/o2oa!1720
胡起 5 лет назад
Родитель
Сommit
b92dd856f7

+ 28 - 5
o2web/source/x_component_process_Xform/DatagridMobile.js

@@ -157,6 +157,12 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                         return value;
                     }
                     break;
+                case "Textarea":
+                    var reg = new RegExp("\n","g");
+                    var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+                    var reg3 = new RegExp("\u003e","g");
+                    value = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
+                    break;
             }
         }
         return value;
@@ -212,10 +218,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
 
                             var module = this.editModules[index];
                             if( module && module.json.type == "ImageClipper" ){
-                                this._createImage( cell, module, v )
+                                this._createImage( cell, module, v );
                             }else{
                                 text = this._getValueText(index, v);
-                                cell.set("text", text);
+                                if( module && module.json.type == "Textarea" ){
+                                    cell.set("html", text);
+                                }else{
+                                    cell.set("text", text);
+                                }
+                                //cell.set("text", text);
                             }
 
 
@@ -297,7 +308,12 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                                 this._createImage( cell, module, v )
                             }else{
                                 text = this._getValueText(index, v);
-                                cell.set("text", text);
+                                if( module && module.json.type == "Textarea" ){
+                                    cell.set("html", text);
+                                }else{
+                                    cell.set("text", text);
+                                }
+                                //cell.set("text", text);
                             }
 
                             // if (typeOf(v)==="object"){
@@ -682,7 +698,14 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
                     if( module.json.type == "ImageClipper" ){
                         this._createImage( cell, module, data.text );
                     }else{
-                        cell.set("text", data.text.join(", "));
+                        var text = this._getValueText(idx, data.text.join(", "));
+                        if( module.json.type == "Textarea"){
+                            cell.set("html", text);
+                        }else{
+                            cell.set("text", data.text.join(", "));
+                        }
+
+                        //cell.set("text", data.text.join(", "));
                     }
                 }else{
                     dataRow = table.insertRow(idx);
@@ -1466,4 +1489,4 @@ MWF.xApplication.process.Xform.DatagridMobile$Data =  new Class({
             }.bind(this));
         }
     }
-});
+});

+ 25 - 5
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -194,6 +194,12 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 						return value;
 					}
 
+					break;
+				case "Textarea":
+					var reg = new RegExp("\n","g");
+					var reg2 = new RegExp("\u003c","g"); //尖括号转义,否则内容会截断
+					var reg3 = new RegExp("\u003e","g");
+					value = value.replace(reg2,"&lt").replace(reg3,"&gt").replace(reg,"<br/>");
 					break;
 				// case "address":
 				// 	if (typeOf(value)==="array"){
@@ -221,7 +227,12 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 			if( module && module.json.type == "ImageClipper" ){
 				this._createImage( cell, module, text )
 			}else{
-				cell.set("text", text);
+				if( module && module.json.type == "Textarea" ){
+					cell.set("html", text);
+				}else{
+					cell.set("text", text);
+				}
+				// /cell.set("text", text);
 			}
 			cell.addEvent("click", function(e){
 				this._editLine(e.target);
@@ -460,7 +471,12 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 					if( module.json.type == "ImageClipper" ){
 						this._createImage( cell, module, data.text );
 					}else{
-						cell.set("text", data.text.join(", "));
+						var text = this._getValueText(idx-1, data.text.join(", "));
+						if( module.json.type == "Textarea"){
+							cell.set("html", text);
+						}else{
+							cell.set("text", data.text.join(", "));
+						}
 					}
 				}else{
 					this._createNewEditTd(newTr, idx, editorTds[idx].get("id"), data.text.join(", "), titleThs.length-1);
@@ -723,10 +739,14 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 
 							var module = this.editModules[index];
 							if( module && module.json.type == "ImageClipper" ){
-								this._createImage( cell, module, v )
+								this._createImage( cell, module, v );
 							}else{
 								var text = this._getValueText(index, v);
-								cell.set("text", text);
+								if( module && module.json.type == "Textarea" ){
+									cell.set("html", text);
+								}else{
+									cell.set("text", text);
+								}
 							}
 
 
@@ -1252,4 +1272,4 @@ MWF.xApplication.process.Xform.DatagridPC$Data =  new Class({
 			}.bind(this));
 		}
 	}
-});
+});