在这种情况下如何获取父值(使用 Telerik Panel Bar)
使用 telerik 面板栏
Html.Telerik().PanelBar()
.Name("PanelBar")
.BindTo(Model, mappings =>
{
mappings.For<Category>(binding => binding
.ItemDataBound((item, category) =>
{
item.Text = category.CategoryName;
})
.Children(category => category.Products));
mappings.For<Product>(binding => binding
.ItemDataBound((item, product) =>
{
item.Text = product.ProductName;
}));
})
http://www .telerik.com/help/aspnet-mvc/telerik-ui-components-panelbar-data-binding.html
我需要的是根据 categoryID
和 生成一个 URL ProductID
即:
.Children(category => category.Products));
mappings.For<Product>(binding => binding
.ItemDataBound((item, product) =>
{
item.Text = product.ProductName;
item.Url = (Get at the parent to get the categoryid somehow) + "/Details/" + product.productID;
}));
但我不知道如何访问任何类别字段。
我无法从产品中获取它,因为它将是一对多,并且我将拥有 product.Categories.
linq 方法
干杯
Using telerik Panel Bar
Html.Telerik().PanelBar()
.Name("PanelBar")
.BindTo(Model, mappings =>
{
mappings.For<Category>(binding => binding
.ItemDataBound((item, category) =>
{
item.Text = category.CategoryName;
})
.Children(category => category.Products));
mappings.For<Product>(binding => binding
.ItemDataBound((item, product) =>
{
item.Text = product.ProductName;
}));
})
http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-panelbar-data-binding.html
What I need is to generate a URL based on categoryID
and productID
i.e. :
.Children(category => category.Products));
mappings.For<Product>(binding => binding
.ItemDataBound((item, product) =>
{
item.Text = product.ProductName;
item.Url = (Get at the parent to get the categoryid somehow) + "/Details/" + product.productID;
}));
But I can't figure out how I can access any of the category fields.
And I can't get it from product because it will be one-many, and i'll have product.Categories.
linq methods
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尽管我不想,但我设法像这样存储该值:
想知道是否有人最终得到了更干净的解决方案
Although I didn't want to, I managed to store the value like this:
Wonder if anyone ends up with a cleaner solution