码迷,mamicode.com
首页 > Web开发 > 详细

easyui-datagrid行数据field原样输出html标签

时间:2015-10-11 11:26:37      阅读:237      评论:0      收藏:0      [点我收藏+]

标签:

easyui-datagrid 绑定的行 field 原样输出html标签。处理效果如图:

技术分享

 

Html页面代码如下:

...
<tr>
        <th field="id" width="5" align="center">编号</th>
        <th field="name" width="20" align="center" data-options="formatter:formatEncodeHtml">名称</th>
...

处理的js代码如下:

function formatEncodeHtml(value, row, index) {
    return encodeHtml(value);
}
this.REGX_HTML_ENCODE = /"|&|‘|<|>|[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g;
function encodeHtml(s) {
    return (typeof s != "string") ? s :
            s.replace(this.REGX_HTML_ENCODE,
                    function ($0) {
                        var c = $0.charCodeAt(0), r = ["&#"];
                        c = (c == 0x20) ? 0xA0 : c;
                        r.push(c);
                        r.push(";");
                        return r.join("");
                    });
}

 

 

  

 

easyui-datagrid行数据field原样输出html标签

标签:

原文地址:http://www.cnblogs.com/vipstone/p/4868954.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!