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

2 posts, 0 answers
  1. mahmoud
    mahmoud avatar
    1 posts
    Member since:
    Aug 2013

    Posted 28 Aug 2013 Link to this post

    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;}
    }
  2. Vladimir Iliev
    Admin
    Vladimir Iliev avatar
    2192 posts

    Posted 30 Aug 2013 Link to this post

    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!
Back to Top