Sunday, 15 July 2012

asp.net mvc - KendoUI Grid. Multiple values in a column -



asp.net mvc - KendoUI Grid. Multiple values in a column -

i'm working on asp.net mvc 4.5 project razor , kendoui. have next 2 classes:

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

but not know how create grid has columns:

column rol.name | column rol.description | column rol.active | column rol.permissions.name(list)

and spport crud operations of kendoui

in view have:

@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 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")) ) )

you need create property in rol called like

string permissionlist { ( homecoming [convert permissions collection string of values]; ) }

this property can phone call permissions , convert string listing names, presumably. not seek in grid, in rol class. suggest renameing rol rolemodel , permission permissionmodel, preference.

asp.net-mvc kendo-ui kendo-grid razor-2

No comments:

Post a Comment