i added a kendo grid in my view.The datasource of that grid is coming from the action method Products_Read in my controller.I had used entity data model in my project.I had added out controller and view code of my index action.The problem is that the data is not coming in grid.
Controller Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using MvcApplication1.Models;
namespace MvcApplication1.Controllers
{
public class HomeController : Controller
{
public ActionResult Index()
{
ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
return View();
}
public ActionResult About()
{
ViewBag.Message = "Your app description page.";
return View();
}
public ActionResult Contact()
{
ViewBag.Message = "Your contact page.";
return View();
}
public ActionResult Products_Read([DataSourceRequest]DataSourceRequest request)
{
using (var northwind = new productTableEntities())
{
IQueryable<product> products = northwind.products;
DataSourceResult result = products.ToDataSourceResult(request);
return Json(result);
}
}
}
}
View Code(section where I have used Grid):
<%: Html.Kendo().Grid<MvcApplication1.Models.product>()
.Name("grid")
.DataSource(dataSource => dataSource // Configure the grid data source
.Ajax() // Specify that ajax binding is used
.Read(read => read.Action("Products_Read", "Home")) // Set the action method which will return the data in JSON format
)
.Columns(columns =>
{
columns.Bound(product => product.id);
columns.Bound(product => product.name);
}).Pageable().Sortable()
%>