I have a simple Kendo UI grid setup for serverside processing which displays some employee information. The grid displays just fine when i first load the view but as soon as you click on a column to sort it refreshes and just gives me an empty grid. The Action is firing each time a column header is click and is returning the correct amount of records to the view. See my code below:
View:
@ModelType List(Of ConnectEntities.Employee)
@Code
ViewData("Title") = "CompanyDirectory"
Layout = "~/Views/Shared/_HomeLayout.vbhtml"
End Code
<
div
class
=
"row"
>
<
div
class
=
"col-md-12"
>
<
div
class
=
"panel panel-primary"
>
<
div
class
=
"panel-heading"
>
<
h4
>Company Directory</
h4
>
</
div
>
<
div
class
=
"panel-body"
>
@Code
Html.Kendo.Grid(Of ConnectEntities.Employee)() _
.Name("employeeDirectory") _
.BindTo(DirectCast(ViewData("employees"), IEnumerable(Of ConnectEntities.Employee))) _
.Columns(Sub(c)
c.Bound(Function(p) p.FirstName_AD).Sortable(True)
c.Bound(Function(p) p.LastName_AD)
c.Bound(Function(p) p.JobTitle_AD)
c.Bound(Function(p) p.PhoneNumber_AD)
End Sub) _
.DataSource(Sub(d)
d.Server() _
.Read(Function(read) read.Action("Person_Read", "Home"))
End Sub) _
.Sortable() _
.Filterable() _
.Render()
End Code
</
div
>
</
div
>
</
div
>
</
div
>
Controller Code:
Function
CompanyDirectory()
As
ActionResult
Dim
employees
As
List(Of ConnectEntities.Employee)
Using connectDB
As
New
ConnectEntities.ConnectEntities
employees = connectDB.Employees.ToList
End
Using
ViewData(
"employees"
) = employees
Return
View()
End
Function
Public
Function
Person_Read()
As
ActionResult
Dim
employees
As
List(Of ConnectEntities.Employee)
Using connectDB
As
New
ConnectEntities.ConnectEntities
employees = connectDB.Employees.ToList
End
Using
Return
View(
"CompanyDirectory"
, employees)
End
Function