This is a migrated thread and some comments may be shown as answers.

The Grid will not load

1 Answer 211 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
EllinDev2
Top achievements
Rank 1
EllinDev2 asked on 18 Apr 2013, 09:21 PM
Hi, 

I am using MVC4 with Entity Framework 5 and I have the following piece of code that I got using samples posted on your website. Apparently, the Grid does not load at all. Am I missing something here?

I do want to mention that the Admin controller is in an "Admin" Area and I have routed requests to the Admin section correctly. Also the UnitOfWork object returns an IEnumerable object which I transpose to Kendo's DataSourceRequest. Currently, this function returns two objects in my test cases and I can see that when I go directly to the url that is bound to the read portion of the dataSource object.

Below is the Controller code.
Imports PropertyCentral.Domain.Entities
Imports PropertyCentral.Domain.Interfaces
Imports PropertyCentral.Domain.Repositories
 
Imports Kendo.Mvc.UI
Imports Kendo.Mvc.Extensions
 
Namespace Admin.Controllers
 
    '<Authorize(Roles:="Administrator")>
    Public Class UsersController
        Inherits System.Web.Mvc.Controller
 
        Private _uow As IUnitOfWork
 
        Public Sub New(uow As IUnitOfWork)
            If uow Is Nothing Then
                Throw New ArgumentNullException("uow")
            End If
            _uow = uow
        End Sub
 
        '
        ' GET: /Admin/Users
        Function Index() As ActionResult
            Dim users = _uow.Users.SelectAll().AsEnumerable()
            Return View("~/Areas/Admin/Views/Users/Index.vbhtml", users)
        End Function
 
        '
        ' GET: /Admin/Users/Users_Read
        Function Users_Read(<DataSourceRequest()> request As DataSourceRequest) As ActionResult
            Dim users = _uow.Users.SelectAll().AsEnumerable()
            Return Json(users.ToDataSourceResult(request), JsonRequestBehavior.AllowGet)
        End Function
 
    End Class

End Namespace

Here is the View:

@ModelType System.Collections.Generic.IEnumerable(Of PropertyCentral.Domain.Entities.User)
 
@Code
    ViewData("Title") = "Administration/Users"
    Layout = "~/Views/Shared/_Layout.vbhtml"
End Code
 
<div class="widget-box">
    <div class="widget-title">
        <span class="icon">
            <i class="icon-th"></i>
        </span>
        <h5>Users</h5>
    </div>
    <div class="widget-content nopadding">
        @*<div id="userGrid" style="height:380px;"></div>  *@
        @Code
             
            Html.Kendo.Grid(Of PropertyCentral.Domain.Entities.User)(Model) _
                .Name("UserGrid") _
                .Columns(Sub(column)
                                 column.Bound(Function(u) u.UserID)
                                 column.Bound(Function(u) u.UserName)
                                 column.Bound(Function(u) u.FirstName)
                                 column.Bound(Function(u) u.LastName)
                                 column.Bound(Function(u) u.EmailAddress)
                                 column.Bound(Function(u) u.PhoneNumber)
                         End Sub) _
                .DataSource(Sub(dataSource)
                                    dataSource _
                                        .Ajax() _
                                        .Read(Sub(read)
                                         read.Action("Users_Read", "Users", New With {.Area = "Admin"})
                                              End Sub)
                            End Sub)
        End Code
    </div>
</div>
Could you please tell me why the Grid won't load the data?

Thanks,
Akshay

1 Answer, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 22 Apr 2013, 08:58 AM
Hello,

Few questions to your case:

Are there any JavaScript errors in the console? Is there Ajax request at all? If there is what is the actual response from the server? 

Are the kendo.aspnetmvc.min.js scripts added?

If everything is going as expected please put this into a demo project which we can run so we can investigate further.

Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
EllinDev2
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Share this question
or