2013-02-17 2 views
0

저는 Razor와 KendoUI로 ASP.NET MVC 4.5 프로젝트를 만들고 있습니다. | Rol.Name와KendoUI Grid. 열의 다중 값

열 : 나는 다음과 같은 두 개의 클래스가 있습니다

public class Rol 
    { 
     [Key] 
     [ScaffoldColumn(false)] 
     public int RolId { get; set; } 

     [Required] 
     [MaxLength(50)] 
     public string Name{ get; set; } 

     [MaxLength(255)] 
     public string Desciption { get; set; } 

     public bool Active{ get; set; } 

     [DisplayName("Permissions")] 
     public virtual ICollection<Permission> Permissions { get; set; } 
    } 

public class Permission 
    { 
     [Key] 
     [ScaffoldColumn(false)] 
     public int PermisoId { get; set; } 

     [Required] 
     [MaxLength(50)] 
     public string Name { get; set; } 

     [MaxLength(255)] 
     public string Description { get; set; } 

     public bool Active { get; set; } 

     public ICollection<Rol> Rols { get; set; } 
    } 

을하지만 열이 그리드를 만드는 방법을 알고하지 않습니다 Rol.Description | Rol.Active | 모든 Rol.Permissions.Name (목록)와 열

그리고보기에서

을 KendoUI

의 CRUD 작업을 spport 내가 가진 :

@model IEnumerable<ItemsMVC.Models.Rol>  
    @(
     Html.Kendo().Grid(Model) 
      .Name("Grid") 
      .Columns(c => 
       { 
        c.Bound(p => p.RolId).Visible(false); 
        c.Bound(p => p.Name); 
        c.Bound(p => p.Description); 
        c.Bound(p => p.Active) 
         .ClientTemplate("#= Active ? 'yes' : 'No' #") 
         .Width(100); 
        **HERE THE LIST OF PERMISSIONS** 
        c.Command(p => { 
         p.Edit(); 
         p.Destroy(); 
        }).Width(200); 
       }   
      )   
      .Pageable(p => p.Enabled(true)) 
      .Scrollable(s => s.Enabled(true)) 
      .Sortable(s => s.Enabled(true)) 
      .Filterable(f => f.Enabled(true)) 
      .ColumnMenu(c => c.Enabled(true)) 
      .ToolBar(t => t.Create()) 
      .Editable(e => e.Mode(GridEditMode.PopUp)) 
      .DataSource(ds => ds 
       .Ajax() 
       .Model(model =>model.Id(p => p.RolId)) 
       .Create(c => c.Action("EditingInline_Create", "Rol")) 
       .Read(r => r.Action("Permisos_Read","Rol")) 
       .Update(u => u.Action("EditingInline_Update", "Rol")) 
       .Destroy(d => d.Action("EditingInline_Destroy", "Rol")) 
      ) 
    ) 
+0

열에 여러 필드를 구성하는 데 ClientTemplate을 사용합니다. – OnaBai

답변

0

당신은 Rol을 뭔가라는 또 다른 속성을 만들어야합니다 like

string PermissionList 
{ 
    get (return [Convert Permissions collection to string of values];) 
} 

이 속성은 Permissions를 호출하고 이름을 나열하는 문자열로 변환 할 수 있습니다. Grid에서이 작업을 시도하지 마십시오. Rol 클래스에서 수행하십시오. RoleModel에 대한 Rol 및 PermissionModel에 대한 Permission의 이름을 변경하는 것이 좋습니다.