在textarea文本域出 "\r\n" 换不到行
请问如何解决?

解决方案 »

  1.   

    设置一下
    { xtype: "textarea", fieldLabel: "备注", name: "", anchor: "96.7%", height: 40}
    textarea会自动换行
      

  2.   

    这个是经过转义了,不能用\r\n,你直接entry换行试试。
      

  3.   

    从数据库中读出来可以replace掉,给textarea  setValue() 会自动换行。
      

  4.   


    后台
    <%@ WebHandler Language="C#" Class="detailSection" %>using System;
    using System.Web;
    using System.Web.Script.Serialization;
    using System.Configuration;
    using System.Data.SqlClient;
    using System.Data;
    using System.Collections.Generic;
    using System.Text.RegularExpressions;
    public class jsondataSection
    {
         public string cFunction;
    }public class detailSection : IHttpHandler {    public List<jsondataSection> jsdatasection = new List<jsondataSection>();
        
        public void ProcessRequest (HttpContext context) {
            context.Response.ContentType = "text/xml";
            context.Response.Charset = "UTF-8";
            string cid = context.Request["Cid"];        string sql = "select * from DeptInfo where cDeptId='"+cid+"'";        string _conn = ConnectionString.ZGBTHumanResource();
            SqlDataReader sdr = DAL.SqlHelper.ExecuteReader(_conn, CommandType.Text, sql);        while (sdr.Read())
            {
                  string a = sdr["cFunction"].ToString().Replace("\r\n", "<br>");
                jd.cFunction = a;
                jsdatasection.Add(jd);        }
            context.Response.Write(ToJson(jsdatasection.ToArray()));
        }    public string ToJson(object o)
        {
            JavaScriptSerializer j = new JavaScriptSerializer();
            return j.Serialize(o);
        }
        
        public bool IsReusable {
            get {
                return false;
            }
        }}
    前台jsfunction detail_Section(cid) {
        Ext.Ajax.request({
            url: "BTSystemOA/btrlzy/ConfiguringManagement/SectionManagement/detailSection.ashx"
            , async: false
            , success: function(response, config) {            var data = response.responseText;             var a = data.substring(2, data.length - 2); /
                var b = a.split(",");               var itemarry = new Array();
                for (var i = 0; i < b.length; i++) { 
                    var c = b[i].split(":");  
                    for (var j = 0; j < c.length; j++) {
                        if (!j % 2 == 0) {                          var d = c[j].substring(1, c[j].length - 1); 
                            itemarry.push(d); 
                        }
                    }
                }            for (var k = 0; k < itemarry.length; k++) {
                    Ext.getCmp('cFunction').setValue(itemarry[0]);
                }
            }
            , failure: function() {
                Ext.MessageBox.alert('请注意', '菜单加载出错,请稍后再试!');
            }
         , method: "post"
         , params: { Cid: cid, t: Math.random() }
        });全部代码
      

  5.   

    直接用\r\n不要替换<br>看看
      

  6.   


    不替换就是图片那样,
    用<br>替换就是 "\r\n" 变成  "\u003cbr\u003e2"
      

  7.   

    替换成转义字符:
    "\r\n"----->"\\n"