jqGrid添加项目复选框字段默认为选中
问题描述:
下面是一个简单的问题。我有一个工作良好的jqGrid,但我希望设置复选框的默认值以在用户添加新项目时进行检查。下面是一个代码片段:jqGrid添加项目复选框字段默认为选中
{name: "Active", index: "active", width: 80, align: "center", sortable: false,
editable: true, edittype: "checkbox", editoptions: {value: "Yes:No"}}
我没有看到任何文档中:
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"
这样的列。此外
stype: "select", searchoptions: { value: "1:Yes;0:No" }
也可以是有用的,如果你允许从列中搜索值。
修订:免费的jqGrid 4.13.6(目前4.13.6-前,其中一个可以从GitHub获取)支持新stype: "checkbox"
。可以使用例如
stype: "checkbox", searchoptions: { sopt: ["eq"], value: "true:false" }
在过滤器工具栏中有3状态复选框,在搜索对话框中有2状态复选框。以上searchoptions.value
值表示选中的框对应的值为“true”,未选中的框的值为“false”。
答
我已经使用了它,它工作。
editoptions: {value: "true:false", defaultValue: "true"}
+0
谢谢你很好的答案.. – Rajpurohit 2014-01-09 11:45:40
Prefect解决方案,并感谢您的建议。 – gurun8 2010-06-10 04:25:30