Jqgrid和复选框

时间:2012-06-17 18:47:05

标签: jquery jquery-plugins jqgrid

我正在使用jqgrid,我的复选框有问题。

我的数据库中有一列返回'S' --> true'N'--> false

我在互联网上看过一些例子,我选择了这种方式(认为这是正确的):

{name:'acc_web', index:'acc_web', width:60, editable:true, edittype:"checkbox", formatter:"checkbox",editoptions: {value:"S:N"}},   

但是,这始终会选中true复选框。这里有什么不对吗?此外,我把它作为editable,但我做不到!

整个代码是这样的:

$(document).ready(function () {

    jQuery("#list2").jqGrid({ 
        url:'obtieneUsuarios.do', 
        datatype: "json", 
        colNames:['Acceso web','Primer apellido','Segundo apellido','Nombre','Login', 'Perfil'], 
        colModel:[ 
            {name:'acc_web', index:'acc_web', width:60, editable:true, edittype:"checkbox", formatter:"checkbox",editoptions: {value:"S:N"}},               
            {name:'apellido1',index:'apellido1', width:200},
            {name:'apellido2',index:'apellido2', width:200},
            {name:'nombre',index:'nombre', width:160},               
            {name:'login',index:'login', width:100}, 
            {name:'perfil',index:'perfil', width:160}
        ], 
        width: 820,
        height: 200,
        rowNum:10, 
        rowList:[5,10,20], 
        pager: '#pager2', 
        sortname: 'apellido1', 
        viewrecords: true, 
        sortorder: "asc", 
        caption:"Listado de usuarios"
    }); 
    jQuery("#list2").jqGrid('navGrid','#pager2',{edit:false,add:false,del:false});
});

1 个答案:

答案 0 :(得分:0)

(在问题编辑中由OP回答。转换为社区维基答案。请参阅Question with no answers, but issue solved in the comments (or extended in chat)

OP写道:

  

最后我解决了这个问题:

     

jqgrid中的复选框仅将某些属性识别为false,0,No,undefined等等。我只需要将结果映射到这些结果。在这种情况下:'S' --> 1'N' --> 0。通过这种映射,解决了问题:)