I have a KendoUI Grid where I am displaying a lot of information. To keep things simple I have redacted it here. On one of these columns I have a name PayManager when it is in display mode. When I click Edit the name column is then dispayed as a ComboBox.
This all works fine. However, there is one thing I cannot work out how to do. I would like it so that when you click on Edit the Selected value in the ComboBox is the same one as is displayed in the ClientTemplate.
Thanks for any help in advance
Grid
@(Html.Kendo().Grid((IEnumerable<TestDirectoryManager.Models.TestDirectoryDetail>) ViewBag.TestDetails)
.Name("TestGrid")
.HtmlAttributes(new { style = "height:850px;" })
.Columns(columns =>
{
columns.Bound(m => m.PayManagerId).Width(150).Title("PM").Template(p => p.PayManager).EditorTemplateName("PayManagerDropDown");
columns.Command(command => command.Edit()).Title("Actions");
})
.Editable(editable => editable.Mode(GridEditMode.InLine))
.Filterable()
.Groupable()
.Pageable() // Enable pageing
.Scrollable(scr=>scr.Height("auto"))
.Sortable() // Enable sorting
.DataSource(dataSource => dataSource
.Server()
.PageSize(15)
.Model(model =>
{
model.Id(p => p.SomeId);
model.Field(m => m.PayManagerId);
})
// Configure CRUD -->
.Update(update => update.Action("Update", "Home"))
// <-- Configure CRUD
))
ComboBox - PayManagerDropDown.cshtml
@(Html.Kendo().ComboBox()
.Name("PayManagerId")
.Filter(FilterType.StartsWith)
.HtmlAttributes(new {style = "width:auto;"})
.Placeholder("Type beginning of name to select new pay manager")
.DataTextField("FullName")
.DataValueField("userid")
.AutoBind(true)
.Suggest(true)
.DataSource(source => source.Read(read => read.Action("GetUsers", "Home")).ServerFiltering(false)))
Edit:
In the end I got this to work by combining some of Shaz's suggestions with a few changes of my own.
However, the stuff regarding ClientTemplate did not seem to work until I changed the DataSource from .Server to .DataSource(dataSource => dataSource.Ajax()
Probably not the best fix but it works for now.