I am new to both MVC and Kendo and I am trying to create a grid in Kendo using LINQ SQL in MVC. I can not get it recognize '.Datasource' 'Read' 'Update' or 'Events'
ProductQualityFileFull is my table from the SQL database OptTest is my SQL LINQ.
Controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
using System.Web.Mvc;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using Kendo.Mvc.UI.Fluent;
using Kendo.Mvc.UI.Html;
using BrandOperations.Web.Models;
using System.Data.EntityClient;
using System.Data.EntityModel;
using System.Data.Entity;
namespace BrandOperations.Web.Controllers
{
public class PQAHomeController : Controller
{
public ActionResult Index()
{
OptTestDataContext context = new OptTestDataContext();
return View(context.ProductQualityFileFulls);
}
public partial class GridController : Controller
{
public ActionResult Editing_Popup()
{
return View();
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingPopup_Read([DataSourceRequest] DataSourceRequest request)
{
return Json(ProductQualityFileFull.Read().ToDataSourceResult(request));
}
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult EditingPopup_Update([DataSourceRequest] DataSourceRequest request, OptTestDataContext jobber)
{
if (jobber != null && ModelState.IsValid)
{
ProductQualityFileFull.Update(jobber);
}
return Json(new[] { jobber }.ToDataSourceResult(request, ModelState));
}
}
}
}
My View
@model IEnumerable<BrandOperations.Web.Models.ProductQualityFileFull>
@using Kendo.Mvc.UI;
@using Kendo.Mvc.Extensions;
@(Html.Kendo().Grid(Model)
.Name("DataGrid")
.Columns(columns =>
{
columns.Bound(p => p.Jobber).Title("Jobber Number");
columns.Bound(p => p.Dealer).Title ("Dealer Number");
columns.Bound(p => p.OptInd).Title ("Opt-In");
columns.Bound(p => p.establish_date_time).Title("Update Date");
columns.Bound(p => p.establish_id).Title("Update ID");
columns.Command(command => { command.Edit(); }).Width(160);
})
.ToolBar(toolbar => toolbar.Create ())
.Editable(editable => editable.Mode(GridEditMode.PopUp))
.Filterable()
.Pageable()
.Scrollable()
.HtmlAttributes(new object { style = "height:430px;"})
.Datasource( d => d
.Ajax ()
.PageSize (20)
.Events(events => events.Error ("error_handler"))
.Read(read => read.Action ("EditingPopup_Read", "DataGrid"))
.Update(update => update.Action ("EditingPupup_update", "DataGrid"))
.Sort(Sort =>
{
Sort.Add(Model => Model.Jobber).Desecnding;
})
)
)
<script type="text/javascript">
function error_handler(e) {
if (e.errors) {
var message = "Errors: \n";
$.each(e.errors, function (ley, value) {
if ('errors' in value) {
$.each(value.errors, function () {
message += this + "\n";
});
}
});
alert(message);
}
} </script>