template net mvc kendo event create batch asp asp.net-mvc razor drop-down-menu kendo-grid mvc-editor-templates

asp.net mvc - net - Actualizar la grilla de Kendo con el valor de la lista desplegable del editor



telerik asp net mvc grid api (3)

Tengo una red Kendo configurada así:

@(Html.Kendo().Grid<ParticipatingDentalEE>() .Name("DentalEE") .Columns(columns => { columns.Bound(p => p.State).Title("State").Width(150).EditorTemplateName("State"); columns.Bound(p => p.Count).Title("Count").Width(150); columns.Command(c => { c.Edit(); c.Destroy(); }); }) .DataSource(dataSource => dataSource .Ajax() .Model(m => { m.Id(p => p.State); m.Field(p => p.State).Editable(true); m.Field(p => p.Count).Editable(true).DefaultValue(""); }) .Create(update => update.Action("EditingInline_Create", "Dental")) .Read(read => read.Action("EditingInline_Read", "Dental")) .Update(update => update.Action("EditingInline_Update", "Dental")) .Destroy(update => update.Action("EditingInline_Destroy", "Dental")) ) //.Scrollable() //.Sortable() .Editable(e => e.Mode(GridEditMode.InLine))

)

La columna "Estado" consiste en una plantilla desplegable que se ve así:

@(Html.Kendo().DropDownList() .Name("States") // Name of the widget should be the same as the name of the property .DataValueField("CODE") // The value of the dropdown is taken from the EmployeeID property .DataTextField("NAME") // The text of the items is taken from the EmployeeName property .BindTo((System.Collections.IEnumerable)ViewData["States"]) // A list of all employees which is populated in the controller )

Mi menú desplegable aparece correctamente cuando edito o creo un artículo, pero cuando lo guardo, el valor desplegable no permanece en la cuadrícula. ¿Hay algo más que deba configurar para hacer esto?


No estoy seguro de si esto solucionará su problema, pero las plantillas de editor para mi grilla no funcionaron correctamente hasta que configuré el decorador UIHint en el modelo y el EditorTemplateName en la vista.

P.ej

public class ParticipatingDentalEE { ... [UIHint("State")] // this should be the name of your EditorTemplate public State State { get; set; } }

Yo especulo que UIHint se usa para la grilla en el modo ''vista'', mientras que EditorTemplateName se usa en el modo ''editar'', y ambos son necesarios para unir los dos.


Obviamente, este es un hilo viejo, sin embargo, la solución es usar el método DropDownListFor (en lugar de DropDownList) y no especificar un nombre. Sospecho que Kendo hace una coincidencia interna de nombres para aplicar el valor editado al modelo.

@model int // ...or whatever type works for your model @(Html.Kendo().DropDownListFor(i => i) .DataValueField("CODE") .DataTextField("NAME") .BindTo((System.Collections.IEnumerable)ViewData["States"]))


como dices en tu propio comentario,

.Name("States") // Name of the widget should be the same as the name of the property

es decir, debe coincidir con el nombre de la columna y el nombre de la columna es "Estado", no "Estados".