jqGrid添加项目复选框字段默认为选中 [英] jqGrid add item checkbox field defaulted to checked

查看:934
本文介绍了jqGrid添加项目复选框字段默认为选中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个简单的问题.我有一个运行良好的jqGrid,但我想在用户添加新项目时将复选框的默认值设置为选中.这是一段代码:

Here's a simple question. I have a jqGrid that's working great but I want set the default value for a checkbox to checked when user adds a new item. Here's a snippet of code:

{name: "Active", index: "active", width: 80, align: "center", sortable: false,
 editable: true, edittype: "checkbox", editoptions: {value: "Yes:No"}}

我在文档中什么都没有看到:

I don't see anything in the documentation:

http://www.trirand.com/jqgridwiki/doku .php?id = wiki:common_rules

推荐答案

您可以使用

editoptions: {value: "Yes:No", defaultValue: "Yes"}

(请参阅 http://www.trirand.com /jqgridwiki/doku.php?id=wiki:common_rules#editoptions ).

顺便说一句,我个人总是将formatter: "checkbox"用于像您这样的列.而且

By the way, I personally use always the formatter: "checkbox" for columns like you have. Moreover

stype: "select", searchoptions: { value: "1:Yes;0:No" }

如果您允许从该列中搜索值,

也可能会有所帮助.

can also be helpful if you allow to search for values from the column.

已更新:免费的jqGrid 4.13.6(当前为4.13.6-pre,可以从GitHub获得)支持新的stype: "checkbox".例如,一个可以使用

UPDATED: Free jqGrid 4.13.6 (currently 4.13.6-pre, which one can get from GitHub) supports new stype: "checkbox". One can use, for example

stype: "checkbox", searchoptions: { sopt: ["eq"], value: "true:false" }

在过滤器工具栏中具有3状态复选框,在搜索"对话框中具有2状态复选框.上面的searchoptions.value值表示选中的框对应于值"true",而未选中的框对应于值"false".

to have 3-state checkbox in the filter toolbar and 2-state checkbox in the Searching Dialog. The above searchoptions.value value means that the checked box corresponds the value "true" und unchecked box the value "false".

这篇关于jqGrid添加项目复选框字段默认为选中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆