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

Loading data upon dropdown list changes event via Ajax

0 Answers 40 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Redfield
Top achievements
Rank 1
Redfield asked on 11 Jul 2017, 04:32 AM

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)
        {
            try
            {
                List<Data> ls = new List<Data> { };
                foreach (var item in db.Data.ToList())
                {
                    if (item.Feature_ID== Option.Feature_ID)
                        ls.Add(item);                
                }
                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;
                           $.ajax({
                               data: {"Feature_ID":Selected_Data },
                               url: "/KhachHang/DanhSachKhachTheoLoai",
                               type: "GET",
                               dataType: "json",
                               success: function()
                               {
                                   
                               }
                           });
                     
                      
                   } else {
                       Selected_Data = value;
                       grid.data("kendoGrid").dataSource.filter({});
                   }
               }

No answers yet. Maybe you can help?

Tags
Grid
Asked by
Redfield
Top achievements
Rank 1
Share this question
or