i'm writing a website using kendo grid, and now i'm stuck in displaying the Selective Data when i chose an item on the drop down list, i don't use the Filter action but instead i'm using a Ajax which will call my Jsonresult in the controller. How to make the grid show those items ?
Here is the method in my Controller :
public JsonResult LoadSelection(Categories Option)
{
try
{
List<Product> ls = new List<Product> { };
foreach (var item in db.Product.ToList())
{
if (item.Cate_ID== Option.Cate_ID)
ls.Add(item);
}
return new JsonResult()
{
Data = ls,
MaxJsonLength = Int32.MaxValue,
JsonRequestBehavior = JsonRequestBehavior.AllowGet
};
}
catch (Exception e)
{
return Json(e.Message);
}
and here is my dropdownlist handler :
var dropdown = grid.find("#Item").kendoDropDownList({
dataTextField: "Cate_ID",
dataValueField: "Cate_ID",
autoBind: false,
optionLabel: "All",
dataSource: Shared_Data,
change: function () {
var value = this.value();
if (value) {
Selected_Data = value;
$.ajax({
data: {"ID_LoaiKH":Selected_Data },
url: "/Product/LoadSelection",
type: "GET",
dataType: "json",
success: function()
{
$("#grid_1").data('kendoGrid').dataSource.read();
}
});