Loading data upon dropdown list changes event via Ajax

1 posts, 0 answers
  1. Redfield
    Redfield avatar
    10 posts
    Member since:
    Jun 2017

    Posted 10 Jul 2017 Link to this post

    I have a problem when i try to load my data after choosing one item from my features list, i'm using Ajax and my Jsonresult is fine, after a few debugging tests, but how can i tell the grid to load my data correctly, i'm using code instead of the filter Junction.
    Here is my Controller :
    public JsonResult OptionData(Features Option)
                    List<Data> ls = new List<Data> { };
                    foreach (var item in db.Data.ToList())
                        if (item.Feature_ID== Option.Feature_ID)
                    return new JsonResult()
                        Data = ls,
                        MaxJsonLength = Int32.MaxValue,
                        JsonRequestBehavior = JsonRequestBehavior.AllowGet
                catch (Exception e)
                    return Json(e.Message);

    And my Dropdown List in View 

    var dropdown = grid.find("#Feature).kendoDropDownList({
                   dataTextField: "Feature_Name",
                   dataValueField: "Feature_ID",
                   autoBind: false,
                   optionLabel: "All",
                   dataSource: Shared_Data,           
                   change: function () {
                       var value = this.value();
                       if (value) {
                           Selected_Data = value;
                                   data: {"Feature_ID":Selected_Data },
                                   url: "/KhachHang/DanhSachKhachTheoLoai",
                                   type: "GET",
                                   dataType: "json",
                                   success: function()
                       } else {
                           Selected_Data = value;

Back to Top