0

私は、グリッドがICDの説明とそれに関連するHCCカテゴリの説明を表示する必要がある医療アプリケーションに取り組んでいます。ICDおよびHCCタイプは次のようになります。

public class ICD {
    public String Code { get; set; }

    public String Description { get; set; }

    public HCC HCC { get; set; }
}

public class HCC {
    public Int32 ID { get; set; }

    public String Description { get; set; }
}

Telerik MVC拡張グリッドをICDオブジェクトのリストにバインドすると、次のように列が設定されます。

this.Html.Telerik().Grid(this.Model.ICDs)
    .Name("ICDGrid")
    .DataKeys(keys => keys.Add(icd => icd.Code))
    .DataBinding(binding => {
        binding.Ajax().Select(this.Model.AjaxSelectMethod);
        binding.Ajax().Update(this.Model.AjaxUpdateMethod);
    })
    .Columns(columns => {
        columns.Bound(icd => icd.ICDType.Name).Title("ICD 9/10");
        columns.Bound(icd => icd.Code);
        columns.Bound(icd => icd.Description);
        columns.Bound(icd => icd.HCC.Description).Title("HCC Category")
        columns.Command(commands => commands.Delete()).Title("Actions").Width(90);
    })
    .Editable(editing => editing.Mode(GridEditMode.InCell).DefaultDataItem(new ICD()))
    .ToolBar(commands => {
        commands.Insert();
        commands.SubmitChanges();
    })
    .Sortable()
    .Filterable()
    .Pageable(paging => paging.PageSize(12))
    .Render();

問題は、ICDとHCCの両方に「Description」という名前のプロパティがあり、それを制御できないことです。Telerikに、生成するJavaScriptでそれらを異なるものと呼ぶように指示する方法はありますか?ICDDescriptionやHCCDescriptionのようなものですか?

4

1 に答える 1

1

現在、プロパティのエイリアスを作成することはできません。できることは、プロパティに一意の名前が付けられたViewModelオブジェクトを作成することです。次に、グリッドをViewModelオブジェクトにバインドします。コードスニペットは次のとおりです。

public class ICDViewModel
{
   public string Description
   {
      get;
      set;
   }
   public string HCCDescription
   {
      get;
      set;
   }
   // The rest of the properties of the original ICD class
}

次に、ICDViewModelを使用するようにModel.ICDのタイプを変更する必要があります。拡張メソッドを使用して、SelectICDをICDViewModelにマップできます。

Model.ICDs = icds.Select(icd => new ICDViewModel 
{ 
   Description = icd.Description,
   HCCDescription = icd.HCC.Description
   /* set the rest of the ICD properties */
});
于 2011-05-06T07:50:16.030 に答える