0

I'm new to MVC and trying to produce a view with a Kendo Grid that will bind to a model.

My View has

@ModelType CDB.GridDetail

 @Code
 Html.Kendo().Grid(Model.GridDetailPersons)() _
    .Name("Grid") _
    .Columns(Sub(c) _
             c.Bound(Function(s) s.PersonID End Function) _
             c.Bound(Function(s) s.Status End Function) _
             c.Bound(Function(s) s.OperationalTeam End Function) End Sub) _
    .Pageable() _
    .Sortable() _
    .ToolBar(Function(t) t.Create() _
             t.Custom().Name("myCustomCommand").Text("custom toolbar button") End Function) _
    .Filterable() _
    .DataSource(Function(d) d.Ajax() _
             .PageSize(200) _
             .ServerOperation(False) End Function) _
    .Render()
End Code

My model are

Public Class GridDetail

    Public Property GridDetailPersons As IQueryable(Of Person)
    Public Property Message As String

End Class

and

Imports System.ComponentModel
Imports System.ComponentModel.DataAnnotations

Public Class Person

    <Required, StringLength(50), DisplayName("Person ID")>
    Public Property PersonID As String

    <DisplayName("Status")>
    Public Property Status As String

    <DisplayName("OPs Support Team")>
    Public Property OperationsTeam As String

End Class

Unfortunately I don't seem to be able to bind to my model I get an error in VS (wavy line under Model.GridDetailPersons) which states Class 'GridBuilder(Of Person)' cannot be indexed because it has no default Property.

If I change the line to Html.Kendo().Grid(Of Model.GridDetailPersons)() the error changes to Type 'Model.GridDetailPersons' is not defined.

What am I doing wrong... there is so little out there especially if using razor vb syntax.

My grid will be used for display only... no edit, add or delete will be required.

Mych
  • 2,527
  • 4
  • 36
  • 65
  • not familiar with kendo extensions and VB, but have you tried using a List(Of Person) instead of IQueryable()? Maybe it doesn't like IQueryables – JamieD77 Dec 02 '15 at 16:50
  • 1
    also.. when you tell the Grid what the type of object is, you have to specify the actual type.. not the property name.. so it would look like `Html.Kendo().Grid(Of Person)()` unless you have the namespace imported somewhere, you also have to fully qualify the names – JamieD77 Dec 02 '15 at 16:55
  • 1
    Yeah, I think the IQueryable with the Paging is an issue. When I use paging I'm running my Iqueryable through ToDataSourceResult. Not sure if kendo can work with an Iqueryable to determine page info? If you can, make a controller action that works with DataSourceResult as explained here: http://blog.falafel.com/server-paging-sorting-filtering-kendo-datasourcerequest/ – Steve Greene Dec 02 '15 at 17:04
  • 1
    as far as i know kendo mvc uses System.Web.Script.Serialization.JavaScriptSerializer for serializing model to json – Gene R Dec 02 '15 at 18:14
  • Gentlemen many thanks for your comments. I've managed to sort out this issue. The new code can be found in my next question: http://stackoverflow.com/questions/34062506/adding-view-or-button-link-to-kendo-grid – Mych Dec 03 '15 at 09:47

0 Answers0