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

Grid Datasource read request not being called

2 Answers 137 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Richard
Top achievements
Rank 1
Richard asked on 24 Sep 2014, 09:33 AM
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
@Code
    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.AntiForgeryToken()
 
 @(Html.Kendo().Grid(Of SelectRoleEditorViewModel).Name("Roles") _
     .Columns(Sub(c)
                  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 = Model.id}))) _
     .Pageable())

Controller:
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?
Thanks

2 Answers, 1 is accepted

Sort by
0
James
Top achievements
Rank 1
answered on 24 Sep 2014, 08:59 PM
I'm experiencing the same thing.  Any help would be appreciated.
0
Nikolay Rusev
Telerik team
answered on 25 Sep 2014, 02:41 PM
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.

Regards,
Nikolay Rusev
Telerik
 

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.

 
Tags
Grid
Asked by
Richard
Top achievements
Rank 1
Answers by
James
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or