Hello. Thanks for your reply. I was not aware of the ComboBox. I will have to check it out. I actually got this working after all using the AutoComplete control by utilizing the Select event and saving dataItem value to hidden field inside the AJAX form.
Here is the razor code, controller and service that handles the Grid with AutoComplete update functionality. The AutoComplete is hooked up to an object with Id and Name properties.
RAZOR
@(Html.Kendo().Grid<AppTracker.ViewModels.QueuedAgentViewModel>()
.Name("gridAgents")
.Columns(columns =>
{
columns.Select().Width(50);
columns.Bound(a => a.Agent).ClientTemplate("#= data.Agent ? Agent.FullName : '' # ").Title("Existing Agent").EditorTemplateName("AgentAutoComplete");
columns.Bound(c => c.FirstName);
columns.Bound(b => b.MiddleName).ClientTemplate("#= MiddleName == 'NA' || MiddleName == null ? '' : MiddleName #");
columns.Bound(p => p.LastName);
columns.Bound(p => p.Suffix).ClientTemplate("#= Suffix == 'NA' || Suffix == null ? '' : Suffix #");
columns.Bound(a => a.Dba).Editable("dbaEditable");
columns.Bound(a => a.Npn).Title("NPN");
})
.ToolBar(toolbar => {
toolbar.Custom().IconClass("fal fa-plus-circle").Text(" Add New Agents").HtmlAttributes(new { id = "btnAddAgents", @class="btn-warning"}).Url("#");
toolbar.Save();
})
.Editable(editable => editable.Mode(GridEditMode.InCell))
.Sortable()
.Filterable()
.Pageable()
.NoRecords()
.PersistSelection()
.HtmlAttributes(new { @class="table"})
.DataSource(dataSource => dataSource
.Ajax()
.Batch(true)
.ServerOperation(false)
.Events(events => events.Error("errorHandler"))
.Model(model =>
{
model.Id(p => p.AgentId);
model.Field(e => e.AgentId).Editable(false);
model.Field(e => e.Dba).Editable(false);
})
.PageSize(25)
.Read(read => read.Action("QueuedAgentViewModel_Read", "Data", new { importId = Model.Import_Id }))
.Update(update => update.Action("QueuedAgentViewModel_Update", "Data"))
)
)
CUSTOM EDITOR
@model ResultEntryViewModelCONTROLLER
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult QueuedAgentViewModel_Update([DataSourceRequest] DataSourceRequest request, [Bind(Prefix = "models")]IEnumerable<QueuedAgentViewModel> agents)
{
if(agents != null && ModelState.IsValid)
{
foreach(var agent in agents)
{
QueuedAgentGridService.Update(agent);
}
}
return Json(agents.ToDataSourceResult(request, ModelState));
}
SERVICE
public static void Update(QueuedAgentViewModel agent)
{
AgentDataActions.UpdateQueuedAgent(db, agent.AgentId, agent.FirstName, agent.MiddleName, agent.LastName, agent.Suffix, agent.Npn, agent.Dba ?? "", agent.Agent == null ? 0 : Convert.ToInt32(agent.Agent.Id));
}