JQGrid的MVC版本:设置编辑字段的默认值(下拉列表,文本和复选框)

时间:2012-11-20 15:29:38

标签: asp.net-mvc jqgrid

如何在JQGrid中编辑/搜索字段中设置默认值(使用MVC版本)?

1 个答案:

答案 0 :(得分:2)

设置DropDown的默认值

new JQGridColumn
{ 
   DataField = "myField",
   DataType = typeof(string),
   Editable = true,
   EditType = EditType.DropDown,
   EditFieldAttributes = new List<JQGridEditFieldAttribute>()
   {                                     
      new JQGridEditFieldAttribute(){ Name = "defaultValue", Value = "myDefaultValue"},
   },
},

设置TextBox的默认值

new JQGridColumn
{ 
   DataField = "myField",
   DataType = typeof(string),
   Editable = true,
   EditFieldAttributes = new List<JQGridEditFieldAttribute>()
   {                                     
      new JQGridEditFieldAttribute(){ Name = "value", Value = "myDefaultValue"},
   },
},

默认CheckBox要检查

new JQGridColumn
{ 
   DataField = "myField",
   DataType = typeof(bool),
   Editable = true,
   EditType.CheckBox,
   EditFieldAttributes = new List<JQGridEditFieldAttribute>()
   {                                     
     new JQGridEditFieldAttribute(){ Name = "checked", Value = "checked"},
   },
},