Javascript JQGrid下拉列表
我正在开发使用JQGrid的MVC应用程序。在JQGrid中,我需要显示CountryName,但当数据来自数据库Country属性为null时,我保存了CountryIDJavascript JQGrid下拉列表,javascript,jquery,asp.net,jqgrid,asp.net-mvc-5,Javascript,Jquery,Asp.net,Jqgrid,Asp.net Mvc 5,我正在开发使用JQGrid的MVC应用程序。在JQGrid中,我需要显示CountryName,但当数据来自数据库Country属性为null时,我保存了CountryID public partial class { public int ID { get; set; } public string Name { get; set; } public string Code { get; set; } public int Co
public partial class
{
public int ID { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public int CountryID { get; set; }
public Nullable<System.DateTime> CreatedOn { get; set; }
public Nullable<System.DateTime> UpdatedOn { get; set; }
public string Description { get; set; }
public virtual Country Country { get; set; }
}
jqgrid不知道如何处理列模型中的Country.Name。我建议在你的部分类中有一个名为CountryName的新属性,如下所示
public partial class
{
public int ID { get; set; }
public string Name { get; set; }
public string Code { get; set; }
public int CountryID { get; set; }
public Nullable<System.DateTime> CreatedOn { get; set; }
public Nullable<System.DateTime> UpdatedOn { get; set; }
public string Description { get; set; }
public virtual Country Country { get; set; }
public string CountryName { get{return Country.Name ; }
}
colModel: [
{ key: true, hidden: true, name: 'ID', index: 'ID', sorttype: 'int' },
{ name: 'Name', index: 'Name', editable: true, inlineEditing: { keys: true }, minlength: 6 },
{ name: 'Description', index: 'Description', editable: true, inlineEditing: { keys: true } },
{ name: 'CountryName', index: 'CountryName', editable: true, edittype: "select", editoptions: { value: citySelect() } },
],
colModel: [
{ key: true, hidden: true, name: 'ID', index: 'ID', sorttype: 'int' },
{ name: 'Name', index: 'Name', editable: true, inlineEditing: { keys: true }, minlength: 6 },
{ name: 'Description', index: 'Description', editable: true, inlineEditing: { keys: true } },
{ name: 'CountryName', index: 'CountryName', editable: true, edittype: "select", editoptions: { value: citySelect() } },
],