easyui-datagrid行數據field原樣輸出html標簽


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

easyui-datagrid 綁定的行 field 原樣輸出html標簽。處理效果如圖:

\

 

Html頁面代碼如下:

[html]  view plain  copy
 
  1. ...  
  2. <tr>  
  3.         <th field="id" width="5" align="center">編號</th>  
  4.         <th field="name" width="20" align="center" data-options="formatter:formatEncodeHtml">名稱</th>  
  5. ...  

處理的js代碼如下:

[javascript]  view plain  copy
 
  1. function formatEncodeHtml(value, row, index) {  
  2.     return encodeHtml(value);  
  3. }  
  4. this.REGX_HTML_ENCODE = /"|&|'|<|>|[\x00-\x20]|[\x7F-\xFF]|[\u0100-\u2700]/g;  
  5. function encodeHtml(s) {  
  6.     return (typeof s != "string") ? s :  
  7.             s.replace(this.REGX_HTML_ENCODE,  
  8.                     function ($0) {  
  9.                         var c = $0.charCodeAt(0), r = ["&#"];  
  10.                         c = (c == 0x20) ? 0xA0 : c;  
  11.                         r.push(c);  
  12.                         r.push(";");  
  13.                         return r.join("");  
  14.                     });  
  15. }  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM