Grid Datasource read request not being called

3 posts, 0 answers
  1. Richard
    Richard avatar
    18 posts
    Member since:
    Jun 2014

    Posted 24 Sep 2014 Link to this post

    I am re-wiring a grid from traditional MVC to use a Telerik Grid and have a grid that appears not to be requesting data from the controller:

    @ModelType EditUserViewModel
        ViewData("Title") = "UserRoles"
    End Code
    <h2>Roles for user: @Model.UserName</h2>
    <hr />
    @Using (Html.BeginForm("UserRoles", "Account", FormMethod.Post, New With {.encType = "multipart/form-data", .name = "myform"}))
     @(Html.Kendo().Grid(Of SelectRoleEditorViewModel).Name("Roles") _
                      c.Bound(Function(x) x.Selected)
                      c.Bound(Function(x) x.RoleName)
                      c.Bound(Function(x) x.Description)
                  End Sub) _
        .Editable(Function(editable) editable.Mode(GridEditMode.InLine)) _
        .DataSource(Function(dataSource) dataSource _
                 .Server() _
                 .Model(Sub(model) model.Id(Function(p) p.RoleName)) _
                 .Read(Function(read) read.Action("UserRolesRead", "Account", New With {.id =}))) _

    Public Function UserRolesRead(req As DataSourceRequest, id As String) As ActionResult
        Dim Db = New ApplicationDbContext()
        Dim user = Db.Users.First(Function(u) u.Id = id)
        Dim model As New List(Of SelectRoleEditorViewModel)()
        model = user.Roles
        Return View(model)
    End Function

    GIven this is non-Ajax I'd expect the Grid to 'read' the datasource upon initial rendering, but a breakpoint in the first line of 'UserRolesRead' is never hit and the Grid is rendered empty.

    Anyone any ideas?
  2. James
    James avatar
    40 posts
    Member since:
    Sep 2014

    Posted 24 Sep 2014 Link to this post

    I'm experiencing the same thing.  Any help would be appreciated.
  3. Nikolay Rusev
    Nikolay Rusev avatar
    2289 posts

    Posted 25 Sep 2014 Link to this post

    Hello James,

    The following article explains how to setup the Grid helper for server binding. You will have to provide data in the Grid definition /Html.Kendo().Grid(Model)/ or use BindTo to feed the grid with data.

    Nikolay Rusev

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

Back to Top