Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Kendo UI Grid is not calling READ method

As per the requirement, I am having a Kendo UI grid on my VIEW.But sadlyy, the read function is not being hit in the controller.This is annoying ,I am getting the same problem even though everyhting seems to be as per the documentation provided on http://demos.kendoui.com/web/grid/index.html. Here is my View code:

 @(Html.Kendo().Grid<StudentManagement_Models.Student>()
.Name("studentsGrid")
.Columns(columns =>
{

    columns.Bound(p => p.Id).Groupable(false);
    columns.Bound(p => p.FirstName);
    columns.Bound(p => p.MiddleName);
    columns.Bound(p => p.LastName);
    columns.Bound(p => p.CGPA);



})
    .AutoBind(true)
    .Pageable()
    .Navigatable()
    .Sortable()
    .DataSource(dataSource => dataSource
            .Ajax()
                            .Read(read => read.Action("GetAllStudents", "Student"))
            )
        )

Here is my controller action:

 public ActionResult GetAllStudents([DataSourceRequest] DataSourceRequest request)
    {
        //Thread.Sleep(2000);
        StudentManagement_Models.Student student = new StudentManagement_Models.Student();
        StudentHelper helper = new StudentHelper();
        student.SavedStudents = helper.GetAllStudents();

        return Json(student.SavedStudents.ToDataSourceResult(request));
    }

How would I tackle this ?Am I missing something ?Kindly suggest.

Thanks in advance.

like image 928
Prasanna Avatar asked Dec 04 '22 09:12

Prasanna


1 Answers

Add all of this file in your page

<script src="~/Script/Jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="~/Script/jquery-ui-1.8.20.min.js" type="text/javascript"></script>
<script src="@Url.Content("~/Script/kendo.all.min.js")" type="text/javascript"></script>
<script src="~/Script/kendo.web.min.js" type="text/javascript"></script>
<script src="~/Script/kendo.aspnetmvc.min.js" type="text/javascript"></script>
<link href="~/Content/kendo.common.min.css" rel="stylesheet" type="text/css" />
<link href="~/Content/kendo.default.min.css" rel="stylesheet" type="text/css" />

I think you mis one of the js in your page , probebly Jquery-1.8.1.min.js .

like image 196
Jaimin Avatar answered Jan 17 '23 12:01

Jaimin