2016-06-30 10 views
1

私はJQGridを使用しているMVCアプリケーションを開発しています。 JQGridでは、CountryNameを表示する必要がありますが、CountryIDを保存しています。データがデータベースのものである場合Countryプロパティはnullです。 JavaScriptのJQGrid DropDownListing

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: 'Country.Name', index: 'Country.Name', CountryID: 'name', editable: true, edittype: "select", editoptions: { value: citySelect() } }, 


      ], 

答えて

1

jqgridで

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; } 

    } 

は、あなたの列モデルにCountry.Nameで何をするかしません。私は何を示唆していることは、その後

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() } }, 
      ], 
+0

そのが機能していない、次のようにあなたのCOLモデルを更新し、次のようにCOUNTRYNAMEと呼ばれるあなたのパーシャルクラスの新しいプロパティを持っています。 –

+0

どのように動作していませんか?詳しく説明できますか? –