I've been attempting to translate several Kendo UI Grid examples to VB.Net. I've been trying to get the hierarchical grid example to work.
Can someone tell me why the code below does not work? Removing or commenting out the sub-grid allows the primary grid to work. But as soon as the sub-grid source is added I get the "Invalid template" error in the "Kendo.all.min.js" code. If I tell the IDE to continue the primary grid will display but it is empty.
MVC 3 Razor project
Version: 2012.3.1114
IDE: Visual Studio 2012
View source:
Controller source:
Can someone tell me why the code below does not work? Removing or commenting out the sub-grid allows the primary grid to work. But as soon as the sub-grid source is added I get the "Invalid template" error in the "Kendo.all.min.js" code. If I tell the IDE to continue the primary grid will display but it is empty.
MVC 3 Razor project
Version: 2012.3.1114
IDE: Visual Studio 2012
View source:
@(Html.Kendo().Grid(Of KendoUIMvcApplication1.ViewModels.EmployeeViewModel).Name("Employees") _ .Columns(Sub(columns) columns.Bound(Function(e) e.FirstName).Width(140) columns.Bound(Function(e) e.LastName).Width(140) columns.Bound(Function(e) e.Title).Width(200) columns.Bound(Function(e) e.Country).Width(200) columns.Bound(Function(e) e.City) End Sub) _ .ClientDetailTemplateId("employeesTemplate") _ .Pageable() _ .DataSource(Sub(dataSource) dataSource.Ajax().Read(Sub(read) read.Action("HierarchyBinding_Employees", "Example") End Sub) dataSource.Ajax().PageSize(5) End Sub) _ .Sortable() _ .Events(Sub(events) events.DataBound("dataBound") End Sub))<script id="employeesTemplate" type="text/kendo-tmpl"> @(Html.Kendo().Grid(Of KendoUIMvcApplication1.ViewModels.OrderViewModel).Name("Orders_#=EmployeeID#") _ .Columns(Sub(columns) columns.Bound(Function(o) o.OrderID).Width(101) columns.Bound(Function(o) o.ShipCountry).Width(140) columns.Bound(Function(o) o.ShipAddress).Width(200) columns.Bound(Function(o) o.ShipName).Width(200) End Sub) _ .DataSource(Sub(dataSource) dataSource.Ajax().Read(Sub(read) read.Action("HierarchyBinding_Orders", "Example", New With {.employeeID = "#=EmployeeID#"}) End Sub) End Sub) _ .Pageable() _ .Sortable() _ .ToClientTemplate())</script><script> function dataBound() { this.expandRow(this.tbody.find("tr.k-master-row").first()); }</script>Imports System.Web.MvcImports System.LinqImports System.Data.LinqImports Kendo.Mvc.ExtensionsImports Kendo.Mvc.UIPublic Class ExampleController Inherits System.Web.Mvc.Controller Public Function Hierarchy() As ActionResult Return View() End Function Public Function HierarchyBinding_Employees(<DataSourceRequest> request As DataSourceRequest) As ActionResult Return Json(GetEmployees().ToDataSourceResult(request)) End Function Public Function HierarchyBinding_Orders(employeeID As Integer, <DataSourceRequest> request As DataSourceRequest) As ActionResult Return Json(GetOrders().Where(Function(order) order.EmployeeID = employeeID).ToDataSourceResult(request)) End Function Private Shared Function GetOrders() As IEnumerable(Of ViewModels.OrderViewModel) Dim northwind = New NorthwindDataContext() Dim loadOptions = New DataLoadOptions() loadOptions.LoadWith(Of Order)(Function(o) o.Customer) northwind.LoadOptions = loadOptions Return northwind.Orders.[Select](Function(order) New ViewModels.OrderViewModel() With { _ .ContactName = order.Customer.ContactName, _ .OrderDate = order.OrderDate, _ .OrderID = order.OrderID, _ .ShipAddress = order.ShipAddress, _ .ShipCountry = order.ShipCountry, _ .ShipName = order.ShipName, _ .EmployeeID = order.EmployeeID _ }) End Function Private Shared Function GetProducts() As IEnumerable(Of ViewModels.ProductViewModel) Dim northwind = New NorthwindDataContext() Return northwind.Products.[Select](Function(product) New ViewModels.ProductViewModel() With { _ .ProductID = product.ProductID, _ .ProductName = product.ProductName, _ .UnitPrice = If(product.UnitPrice, 0), _ .UnitsInStock = If(product.UnitsInStock, 0), _ .UnitsOnOrder = If(product.UnitsOnOrder, 0), _ .Discontinued = product.Discontinued, _ .LastSupply = DateTime.Today _ }) End Function Private Shared Function GetEmployees() As IEnumerable(Of ViewModels.EmployeeViewModel) Dim northwind = New NorthwindDataContext() Return northwind.Employees.[Select](Function(employee) New ViewModels.EmployeeViewModel() With { _ .EmployeeID = employee.EmployeeID, _ .FirstName = employee.FirstName, _ .LastName = employee.LastName, _ .Country = employee.Country, _ .City = employee.City, _ .Notes = employee.Notes, _ .Title = employee.Title, _ .Address = employee.Address, _ .HomePhone = employee.HomePhone _ }) End FunctionEnd Class