Click here to Skip to main content
15,891,513 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i am using kendo grid
my controller is here am passing the entity to my model then calling in view

public ActionResult samplem1([DataSourceRequest]DataSourceRequest request)
        {
   
            var t=GetCustomers().ToDataSourceResult(request);

            return Json(t, JsonRequestBehavior.AllowGet);
        }
        private static IEnumerable<Northwindproduct> GetCustomers()
        {
            var northwind = new KaushikEntities();
            var purchCount = northwind.tblEmployees.Count();
            return northwind.tblEmployees.Select(product => new Northwindproduct
            {
                id = product.Id,
                Name = product.Name,
                Gender = product.Gender,
                City = product.City

            });
        }



@( Html.Kendo().Grid<KendoUIMvcApplication2.Models.Northwindproduct>()
   .Name("grid")
      .DataSource(dataSource => dataSource
          .Ajax()
                  .Model(model => model.Id(product => product.id))
                  .Read(read => read.Action("samplem1", "Home") 
          )
      )
      .Columns(columns =>
      {
          columns.Bound(product => product.City);
          columns.Bound(product => product.Name);
          columns.Bound(product => product.Gender);
      })
      .Pageable()
      .Sortable()
)



i need the data to display in a kendo grid but am getting data as
{"Data":[{"id":1,"Name":"Mark","Gender":"Male","City":"London","DateOfBirth":"\/Date(-62135568000000)\/"},{"id":2,"Name":"John","Gender":"Male","City":"Chennai","DateOfBirth":"\/Date(-62135568000000)\/"},{"id":3,"Name":"Mary","Gender":"Female","City":"New York","DateOfBirth":"\/Date(-62135568000000)\/"},{"id":4,"Name":"Mike","Gender":"Male","City":"Sydeny","DateOfBirth":"\/Date(-62135568000000)\/"},{"id":5,"Name":"Scott","Gender":"Male","City":"London","DateOfBirth":"\/Date(-62135568000000)\/"}],"Total":5,"AggregateResults":null,"Errors":null}
Posted
Updated 17-Nov-13 23:08pm
v2
Comments
Jameel VM 18-Nov-13 5:16am    
what is the problem actually?

Inside the .DataSource please mention the pagesize
.PageSize(10)
 
Share this answer
 
1.Use the Namespaces
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;

2.Http get pass to certain view where grid view is there
public ActionResult samplem1()
{
return View();
}

[HttpPost]
public ActionResult samplem1Post([DataSourceRequest]DataSourceRequest request)
{
var GetResult = _revenue.GetFromDatabase();
DataSourceResult result = GetResult. ToDataSourceResult(request);
return Json(result); }



@( Html.Kendo().Grid(Models)
.Name("grid")
.DataSource(dataSource => dataSource
.Ajax()
.Read(read => read.Action("samplem1Post ", "Home")
)
)
.Columns(columns =>
{
columns.Bound(product => product.City);
columns.Bound(product => product.Name);
columns.Bound(product => product.Gender);
})
.Pageable()
.Sortable()
)
 
Share this answer
 
C#
public ActionResult samplem1([DataSourceRequest]DataSourceRequest request)
        {

            var t=GetCustomers().ToDataSourceResult(request);

            return Json(t, JsonRequestBehavior.AllowGet);
        }
        private static IEnumerable<Northwindproduct> GetCustomers()
        {
            var northwind = new KaushikEntities();
            var purchCount = northwind.tblEmployees.Count();
            return northwind.tblEmployees.Select(product => new Northwindproduct
            {
                id = product.Id,
                Name = product.Name,
                Gender = product.Gender,
                City = product.City

            });
        }



@( Html.Kendo().Grid<KendoUIMvcApplication2.Models.Northwindproduct>()
   .Name("grid")
      .DataSource(dataSource => dataSource
          .Ajax()
                  .Model(model => model.Id(product => product.id))
                  .Read(read => read.Action("samplem1", "Home")
          )
      )
      .Columns(columns =>
      {
          columns.Bound(product => product.City);
          columns.Bound(product => product.Name);
          columns.Bound(product => product.Gender);
      })
      .Pageable()
      .Sortable()
)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900