I have kendo grid have some columns and one of these columns is foreign key and implemented as combobox inside editor template and the datasource is a collection of values retrieved from database. when the grid loaded and when edit or insert the first row the read function will run and will get the values from DB but in the second edit or insert the read function will not run and the combobox will retrieve his datasource from the first edit. My question is how to make the combobox run the read function in every edit or insert?
This is my code:
and my view model:
and the EmployeeForeignKeyEditor is in EditorTemplates folder inside Shared:
and read function:
and Employee view model:
This is my code:
columns.Bound(p => p.Employee).ClientTemplate("#=Employee.EmployeeText#").Width(110);//This column for foreign key
and my view model:
[UIHint("EmployeeForeignKeyEditor")]
public EmployeeViewModel Employee { get; set; }
and the EmployeeForeignKeyEditor is in EditorTemplates folder inside Shared:
@model SpinePOCViewModel.ViewModels.EmployeeViewModel
@(
Html.Kendo().ComboBox()
.DataTextField("EmployeeText")
.DataValueField("EmployeeID").Name("Employee")
.Placeholder("Select Employee")
.DataSource(source =>
{
source.Read(read =>
{
read.Action("MarketingCoordinatorcb_Read", "Marketing");
})
.ServerFiltering(true);
})
.AutoBind(false)
)
and read function:
public ActionResult MarketingCoordinatorcb_Read()
{
ViewBag.Employees=SomeFunctionToGetData();
return Json((List<
EmployeeViewModel
>)ViewBag.Employees, JsonRequestBehavior.AllowGet);
}
and Employee view model:
public partial class EmployeeViewModel
{
public int EmployeeID { get; set; }
public virtual string EmployeeText { get;set;}
}