[摘要:easyui-datagrid 綁定的止 field 本樣輸出html標簽。處置懲罰后果如圖: Html頁里代碼以下:...<tr> <th field="id" width="5" align="center">編號</th]
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("");
- });
- }