2011-07-05 14 views
1

は、これが私のjqgridです:jqgridエンコード形式

jQuery(document).ready(function(){ 
    jQuery("#list").jqGrid({ 
    url:'getmessage.asp?query=1&col_empty=3&rand_no'+Math.random(), 
    datatype: "json", 
    colNames:['ID','Title','Username','Commento', 'mail', 'Data','Conferma email','Moderato','Stato','Option'], 
    colModel:[ 
    {name:'1',index:'1', width:80,sortable:false}, 
    {name:'2',index:'2', width:80,editable:false,editoptions:{readonly:false,size:20},editrules:{required:true}}, 
    {name:'3',index:'3', width:80,editable:true,editoptions:{readonly:false,size:20},editrules:{required:true}}, 
    {name:'4',index:'4', width:200,editable:true,edittype:"textarea", editoptions:{rows:"4",cols:"20"},editoptions:{readonly:false,size:20},editrules:{required:true}}, 
    {name:'5',index:'5', width:120, editable:true,editoptions:{readonly:false,size:20},editrules:{required:true}}, 
    {name:'6',index:'6',width:80, sorttype:"datetime",formatter:"date",formatoptions:{"srcformat":"d/m/Y","newformat":"d/m/Y"},editoptions:{"dataInit":function(elm){setTimeout(function(){ 

        jQuery(elm).datepicker({dateFormat:'dd/mm/yy'}); 

        jQuery('.ui-datepicker').css({'font-size':'100%'}); 

       },200);}},editable:true}, 
    {name:'7',index:'7', width:80, sortable:true,editable:true,edittype:"select", editoptions:{value:"1:1;0:0"}} , 
    {name:'8',index:'8', width:80,sortable:true,editable:true,edittype:"select", editoptions:{value:"1:1;0:0"}} , 
    {name:'stato',index:'stato',width:90,sortable:false,editable:false} , 
    {name:'act',index:'act', width:100,sortable:false,editable:false} ], 
pager: jQuery('#pcrud'), 
rowNum:10, 
rowTotal: 50, 
rowList:[10,20,30], 
height: '100%', 
pager: '#pcrud', 
cellEdit: false, 
sortname: '1', 
loadonce: false, 
editurl: 'server.asp?query=1', // this is dummy existing url 
viewrecords: true, 
sortorder: "asc", 
cellsubmit:'clientArray', 
reloadAfterSubmit:true, 
gridComplete: function(){ 

     var ids = jQuery("#list").jqGrid('getDataIDs'); 


      for(var i=0;i < ids.length;i++){ 
       var cl = ids[i]; 
       if (jQuery('#list').getCell(ids[i], '6') == '1' && jQuery('#list').getCell(ids[i], '7') == '1') 
        { 
         jQuery("#list").jqGrid('setRowData',ids[i],{stato:"<font color='#3DB64E'>Approved</font>"}); 
        } 
        else 
        { 
        jQuery("#list").jqGrid('setRowData',ids[i],{stato:"<font color='#FF2323'>Unapproved</font>"}); 
        } 
       be = "<img src='/images/delete_msg.png' style='height:28px;width:28px;' alt='Delete' onclick=\"deleteComment('"+cl+"');\" />"; 
       se = "<img src='/images/unapprove_msg.png' style='height:28px;width:28px;' alt='Suspend' onclick=\"unApproveComment('"+cl+"');\" />"; 
       ce = "<img src='/images/approve_msg.png' style='height:28px;width:28px;' alt='Approve' onclick=\"approveComment('"+cl+"');\" />"; 
       jQuery("#list").jqGrid('setRowData',ids[i],{act:be+se+ce}); } 

     }, 
caption:"Comment"}); 
jQuery("#list").jqGrid('navGrid','#pcrud', 
{}, //options 
{reloadAfterSubmit:true}, // edit options 
{reloadAfterSubmit:true}, // add options 
{reloadAfterSubmit:false}, // del options 
{} // search options 
); 

}); 

私はjqgridと、この文字列を保存します:

 `Sweet Dreams ☆:*´¨`*:☆` 

が、私はこの文字列を持っているデータベースで:

 `Sweet Dreams ☆:*´¨`*:☆` 

データはjqgridに正しく表示されますが、このデータをクエリで取得し、htmlページに表示しようとすると、コード化されたstring.which jqgridを使用してエンコードしますか? autoencodeがデフォルトと、このエンコードによってtrueに設定されている場合

今すぐデータがサーバから来て、私たちはそれを投稿(secutityフィックス)だけでなく、:

答えて

0

jqGridのバージョン3.5.2は、重要な新機能が含まれて。あなたのグリッドを設定する際

あなたは設定で符号化されたデータを望んでいないときこのを上書きすることができ、偽をautoencode:

  $("#grid").jqGrid({ 
        autoencode: false, 
        url: "/Some/Path", 
        // etc....,}); 

は、

http://blogs.teamb.com/craigstuntz/2010/02/08/38548/をさらに詳細については、以下のURLを参照してください。

希望します。

+0

okですがwエンコードの種類はjqgridを使用していますか? – magemello

+0

私は(xss攻撃を防ぐための)エンコードについてはわかりませんが、jqgridのドキュメントではHTMLエンコードされた文字列について述べています。次のURLから "jgrid.htmlDecode"オプションをチェックしてください。 http://www.trirand.com/jqgridwiki/doku.php?id=wiki%3amethods – Harun