您的位置:首页 > 产品设计 > UI/UE

easyUI里的checkbox编辑器行编辑是不会自动勾选问题

2016-10-18 09:52 253 查看
数据源如果有布尔值,那么在UI里,最合适的控件应该就是checkbox了。

easyUI的datagrid中,列的checkbox酱紫设置:

[javascript] view
plain copy

 





{field:'status',title:'Status',width:50,align:'center',  

    editor:{  

        type:'checkbox',  

        options:{  

            on: "true",  

            off: "false"  

        }  

    }  

},  

数据:

[javascript] view
plain copy

 





{"total":28,"rows":[  

    {"productid":"FI-SW-01","unitcost":10.00,"status":true,"listprice":16.50,"attr1":"Large","itemid":"EST-1"},  

    {"productid":"K9-DL-01","unitcost":12.00,"status":true,"listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"},  

    {"productid":"RP-SN-01","unitcost":12.00,"status":true,"listprice":18.50,"attr1":"Venomless","itemid":"EST-11"}  

]}  

这样子就有个问题:

当datagrid里的行处于编辑状态时,checkbox并未能自动带上应有的值,比如本来对应是true,但当checkbox出现时,并没有自动勾选!造成很不好的后果:编辑一次,如果不手动对这个checkbox再打钩一次,那么原本是true,现在就变成了 false !什么毛病。

对应办法是将数据里的布尔值变为字符串:"status":true ==> "status":"true"

[javascript] view
plain copy

 





{"total":28,"rows":[  

    {"productid":"FI-SW-01","unitcost":10.00,"status":"true","listprice":16.50,"attr1":"Large","itemid":"EST-1"},  

    {"productid":"K9-DL-01","unitcost":12.00,"status":"true","listprice":18.50,"attr1":"Spotted Adult Female","itemid":"EST-10"},  

    {"productid":"RP-SN-01","unitcost":12.00,"status":"true","listprice":18.50,"attr1":"Venomless","itemid":"EST-11"}  

]}  



原因猜测:可能是比较值时,on和off里的true和false被当做了字符串,而status的值时布尔值,true=="true" 判断结果为false,所以导致没有勾选。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐