easyui datagrid editor checkbox 选中
2016-12-19 12:17
417 查看
easyui datagrid editor checkbox 选中
在前台如果使用easyui的datagrid需要编辑行时遇到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"} ]}
如果无法更改数据源,但是又需要还原时,就需要这样做了:
{field:'status',title:'Status',width:50,align:'center', editor:{ type:'checkbox', options:{ on: "1", off: "0" } } },
这样就完美的解决了你的问题
当然,如果你的数据 本身就是加了引号的"true"和"false"
那就只需要向最上面那样就行了..
相关文章推荐
- easyui datagrid 分页保持checkbox选中状态
- easyui datagrid组件 单击行 让他不选中 只有单击checkbox的时候才选中
- 关于EasyUI多选,easyui datagrid 分页并保持checkbox选中状态
- EasyUI配置当点击一个datagrid的checkbox选中或取消选中记录的时候刷新另一个datagrid数据的方法
- EasyUI datagrid editor checkbox
- easyui datagrid 分页保持checkbox选中状态
- easyui datagrid checkbox选中事件
- easyui 去除datagrid表头的checkbox 和将某行不能选中
- 解决easyui datagrid加载数据时,checkbox列没有根据checkbox的值来确定是否选中
- easyui datagrid组件 单击行 让他不选中 只有单击checkbox的时候才选中
- easyui datagrid editor checkbox 单击事件
- easyUI-Datagrid设置checkbox时默认选中
- EasyUI DataGrid Checkbox 多选 获取选中行中的内容
- EasyUI多选,easyui datagrid 分页并保持checkbox选中状态
- easyui datagrid 分页保持checkbox选中状态
- easyui datagrid 只有点击checkbox才起选中或者取消作用
- easyui datagrid checkbox选中操作
- 解决easyui datagrid加载数据时,checkbox列没有根据checkbox的值来确定是否选中
- easyui datagrid editor checkbox 单击事件
- jquery-easyui的datagrid在checkbox多选时,行选中不对应,去除高亮的解决方法