I have done all of the steps shown in the following question:
How can I set and get the value of a dropdownlist in a grid in Kendo UI MVC?
But in the end, only the first value of my list apears in the dropdownlist. For example, only "admin". I am unable to select other values in the popup edit mode (the style is dropdown list, but it will not open and the value "admin" is the only one visible).
Here is my View:
@(Html.Kendo().Grid<A.Models.Perm>()
.Name("PermGrid")
.Columns(columns =>
{
columns.Bound(r => r.Id).Visible(false);
columns.Bound(r => r.Name);
columns.Bound(r =>
r.PermType).EditorTemplateName("PermTypeEditor");
columns.Command(command =>
{
command.Edit() ;
});
})
.DataSource(datasoure => datasoure.Ajax()
.Model(model => model.Id(record => record.Id))
.Read(read => read.Action("GetAll", "Permi"))
.Update(update => update.Action("Update",
"Permi"))
.PageSize(10)
)
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Sortable()
.Selectable()
.Events(e => e.Edit("onEdit"))
.Pageable(pageable =>
{
pageable.Refresh(true);
pageable.PageSizes(true);
})
)
Controller:
public ActionResult GetAll([DataSourceRequest] DataSourceRequest request)
{
var Permi = GetPermi();
return Json(Permi.ToDataSourceResult(request, record => new
{
record.Id,
record.Name,
record.PermType,
}));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Update([DataSourceRequest] DataSourceRequest request,
Permission perm)
{
if (perm != null && ModelState.IsValid)
{
_db.Update(perm);
_db.SaveChanges();
}
return Json(ModelState.ToDataSourceResult());
}
private static IEnumerable<Permission> GetPermi()
{
var dbs = new AFBContext();
var list3 = (from Item1 in dbs.Permi.ToList() select Item1);
return list3;
}
Model:
public int Id { get; set; }
public string Name { get; set;
[UIHint("PermTypeEditor")]
public string PermType { get; set; }
TemplateEditor:
@model string
@(Html.Kendo().DropDownList()
.Name("PermType")
.Value(Model)
.SelectedIndex(0)
.BindTo(new string[] { "Admin", "Guest", "Normal" }))
ok its seems it works on firefox and not chrome.