easyUI里的checkbox编辑
发布日期:2021-06-30 17:23:00 浏览次数:2 分类:技术文章

本文共 1202 字,大约阅读时间需要 4 分钟。

数据源如果有布尔值,那么在UI里,最合适的控件应该就是checkbox了。

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

{field:'status',title:'Status',width:50,align:'center',	editor:{		type:'checkbox',		options:{			on: "true",			off: "false"		}	}},
数据:

{"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"

{"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"}]}
什么原因尚不清楚。可能是在checkbox中,值是字符型的。虽然它常被用于呈现布尔值,但它不认识什么布尔值。

转载地址:https://leftfist.blog.csdn.net/article/details/42679841 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:easyUI的getChanges中的inserted
下一篇:CLR程序集里的 ExecuteScalar() 和 @@IDENTITY

发表评论

最新留言

哈哈,博客排版真的漂亮呢~
[***.90.31.176]2024年04月19日 21时43分36秒