This is a migrated thread and some comments may be shown as answers.

Run read event for combobox inside grid in inline mode on every edit or insert

1 Answer 70 Views
Grid
This is a migrated thread and some comments may be shown as answers.
mahmoud
Top achievements
Rank 1
mahmoud asked on 28 Aug 2013, 01:18 PM
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:
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;}
}

1 Answer, 1 is accepted

Sort by
0
Vladimir Iliev
Telerik team
answered on 30 Aug 2013, 07:06 AM
Hi Mahmoud,

 
Most probably the browser is caching the Ajax request data - I would suggest to try turn off the cache:

$.ajaxSetup({ cache: false });
Kind Regards,
Vladimir Iliev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Grid
Asked by
mahmoud
Top achievements
Rank 1
Answers by
Vladimir Iliev
Telerik team
Share this question
or