【发布时间】:2012-12-15 13:14:28
【问题描述】:
我在 asp.net mvc 页面上使用 jqgrid 来实现基本的 CRUD 功能。我的要求是我想在编辑弹出窗口中显示一个下拉菜单,该下拉菜单仅包含静态值,例如新的和现有的。我发现的所有示例都使用editoptions 和dataurl 和buildselect 方法。有没有办法在网格打开时使用静态值构建选择列表?
谢谢
【问题讨论】:
标签: asp.net asp.net-mvc jqgrid
我在 asp.net mvc 页面上使用 jqgrid 来实现基本的 CRUD 功能。我的要求是我想在编辑弹出窗口中显示一个下拉菜单,该下拉菜单仅包含静态值,例如新的和现有的。我发现的所有示例都使用editoptions 和dataurl 和buildselect 方法。有没有办法在网格打开时使用静态值构建选择列表?
谢谢
【问题讨论】:
标签: asp.net asp.net-mvc jqgrid
这很简单。您只需要使用editoptions 的value 属性。类似的东西
{ name: "myColName", width: 100, editable: true, edittype: "select",
editoptions: { value: "New:New;Existing:Existing", defaultValue: "New" }}
或者如果您另外使用工具栏搜索,那么
{ name: "myColName", width: 100, editable: true, edittype: "select", stype: 'select',
editoptions: { value: "New:New;Existing:Existing", defaultValue: "New" },
searchoptions: { sopt: ['eq', 'ne'], value: ':Any;New:New;Existing:Existing' }}
【讨论】:
label 属性。默认情况下,jqGrid 使用来自colName 的值。要覆盖规则,您可以添加 formoptions: {label: "My new label"}