Sir,
I have an asp.net core 2.2 project, and I wanted to use Telerik grid to display data from the MS SQL Server database.
the model
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace SUCOCoreControl.Models.RazorBudget
{
public partial class Header
{
public Header()
{
SubHeader = new HashSet<
SubHeader
>();
}
[StringLength(6)]
public string ProjectID { get; set; }
[StringLength(30)]
public string HeaderID { get; set; }
[StringLength(60)]
public string HeaderENG { get; set; }
[StringLength(60)]
public string HeaderARB { get; set; }
[ForeignKey("ProjectID")]
[InverseProperty("Header")]
public virtual Project Project { get; set; }
[InverseProperty("Header")]
public virtual ICollection<
SubHeader
> SubHeader { get; set; }
}
}
The controller
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using SUCOCoreControl.Models.RazorBudget;
using Kendo.Mvc.UI;
using Kendo.Mvc.Extensions;
using SUCOCoreControl.Data;
namespace SUCOCoreControl.Controllers
{
public class HeadersController : Controller
{
private readonly SUCODbContext _context;
public HeadersController(SUCODbContext context)
{
_context = context;
}
public IActionResult Index([DataSourceRequest] DataSourceRequest request)
{
return Json(_context.Header.ToDataSourceResult(request));
}
public IActionResult Error()
{
return View();
}
}
}
The view
@using SUCOCoreControl.Models.RazorBudget
@{
ViewData["Title"] = "Headers";
Layout = "~/Views/Shared/_Layout.cshtml";
}
<!-- ============================================================== -->
<!-- Page wrapper -->
<!-- ============================================================== -->
<
div
class
=
"page-wrapper"
>
<!-- ============================================================== -->
<!-- Container fluid -->
<!-- ============================================================== -->
<
div
class
=
"container-fluid"
>
<!-- ============================================================== -->
<!-- Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<
div
class
=
"row page-titles"
>
<
div
class
=
"col-md-5 align-self-center"
>
<
h4
class
=
"text-themecolor"
><
a
> @ViewBag.Title</
a
></
h4
>
</
div
>
</
div
>
<!-- ============================================================== -->
<!-- End Bread crumb and right sidebar toggle -->
<!-- ============================================================== -->
<
div
class
=
"row"
>
<
div
class
=
"col-12"
>
<
div
class
=
"card"
>
<
div
class
=
"card-body"
>
<
div
class
=
"col-md-6 col-xs-12"
>
<
div
class
=
"form-inline well well-lg"
>
@(Html.Kendo().Grid<
Header
>()
.Name("Header")
.Columns(columns =>
{
columns.Bound(p => p.ProjectID);
columns.Bound(p => p.HeaderID);
columns.Bound(p => p.HeaderENG);
columns.Bound(p => p.HeaderARB);
columns.Command(command => command.Edit());
})
.Pageable()
.Sortable()
.Filterable()
.Groupable()
.Editable()
.DataSource(dataSource => dataSource
.Ajax()
.ServerOperation(false)
.Read(read => read.Action("Index", "Headers"))
)
)
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
</
div
>
The page is not loading, and the grid of course is not.
I attached the result in the browser.
What I am doing wrong???