Hello,
I'm fairly new to Kendo and having an issue when attempting to pass a CustomerID to a TabStrip from a Grid.
Based on the following article I have tried to follow to get Order data loaded on the TabStrip however I'm running into the below JavaScript error
https://demos.telerik.com/aspnet-core/grid/detailtemplate
Syntax error, unrecognized expression: #tabStrip_#=CustomerID# & Uncaught Error: Syntax error, unrecognized expression: #grid_#=CustomerID#
Please see Grid and TabStrip code below.
@(Html.Kendo().Grid<LewisTestProject.Models.Customer>()
.Name("grid")
.DataSource(dataSource => dataSource
.Ajax()
.Model(model => {
model.Id(p => p.CustomerID);
model.Field(p => p.CustomerID).Editable(false);
})
.PageSize(18)
.Read(read => read.Action("Customers_Read", "Customer"))
.Create(create => create.Action("Customers_Create", "Customer"))
.Update(update => update.Action("Customers_Update", "Customer"))
.Destroy(destroy => destroy.Action("Customers_Destroy", "Customer"))
)
.Columns(columns =>
{
columns.Bound(order => order.CustomerID);
columns.Bound(order => order.CompanyName);
columns.Bound(order => order.ContactName);
columns.Bound(order => order.ContactTitle);
columns.Bound(order => order.Address);
columns.Bound(order => order.City);
columns.Bound(order => order.Region);
columns.Bound(order => order.PostalCode);
columns.Bound(order => order.Country);
columns.Bound(order => order.Phone);
columns.Bound(order => order.Fax);
columns.Command(command =>
{
command.Edit();
command.Destroy();
}
).Title("Actions");
})
.ToolBar(toolbar => {
toolbar.Create();
toolbar.Search();
})
.Pageable()
.Sortable()
.ClientDetailTemplateId("template")
.Events(events => events.DataBound("dataBound"))
.Editable(e => e.Mode(GridEditMode.InLine))
)
<script id="template" type="text/kendo-tmpl">
@(Html.Kendo().TabStrip()
.Name("tabStrip_#=CustomerID#")
.SelectedIndex(0)
.Animation(animation => animation.Open(open => open.Fade(FadeDirection.In)))
.Items(items =>
{
items.Add().Text("Orders").Content(@<text>
@(Html.Kendo().Grid<LewisTestProject.Models.OrderViewModel>()
.Name("grid_#=CustomerID#") // template expression, to be evaluated in the master context
.Columns(columns =>
{
columns.Bound(o => o.CustomerID);
columns.Bound(o => o.OrderID).Title("ID").Width(100);
})
.DataSource(dataSource => dataSource
.Ajax()
.PageSize(5)
.Read(read => read.Action("OrdersDetail_Read", "Customers", new { customerID = "#=CustomerID#" }))
)
.Pageable()
.Sortable()
.ToClientTemplate()
)
</text>
);
//items.Add().Text("Contact Information").Content(
// "<div class='employee-details'>" +
// "<ul>" +
// "<li><label>Country:</label>#= Country #</li>" +
// "<li><label>City:</label>#= City #</li>" +
// "<li><label>Address:</label>#= Address #</li>" +
// "<li><label>Home Phone:</label>#= Phone #</li>" +
// "</ul>" +
// "</div>"
//);
})
.ToClientTemplate()
)
</script>
Any help would be greatly appreciated.
Thanks,
Lewis.