Grid showing no records after sort

2 posts, 0 answers
  1. Andrew
    Andrew avatar
    9 posts
    Member since:
    Dec 2013

    Posted 17 Jun Link to this post

    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

     

     

  2. Pavlina
    Admin
    Pavlina avatar
    6084 posts

    Posted 21 Jun Link to this post

    Hello,

    The code looks correct, therefore in order to assist you in resolving this problem please isolate it in a runnable project and send it to us via support ticket, so we can debug it locally and see what is causing the unexpected behavior.

    Regards,
    Pavlina
    Telerik
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
  3. UI for ASP.NET MVC is VS 2017 Ready
Back to Top