jqgrid编码格式

时间:2011-07-05 18:44:34

标签: javascript jquery

这是我的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?

1 个答案:

答案 0 :(得分:0)

jqGrid版本3.5.2包含一个重要的新功能:

现在 autoencode默认设置为true ,这会对来自服务器的数据进行编码,而不仅仅是在我们发布时(保密修复)。

当您在设置网格时设置autoencode false 时不想要编码数据时可以覆盖此

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

有关详细信息,请参阅以下网址

http://blogs.teamb.com/craigstuntz/2010/02/08/38548/

希望这会有所帮助..