Hi guys,
I'm working with the asp.net MVC panelbar. I have succeeded in creating the databound panelbaritems but I don't know how to create the child items.
I have one class
public class Item
{
public string Header{get;set;}
public string Description{get;set;}
public DateTime PostedDateTime{get;set;}
}
The panelbaritems contain the PostedDateTime and the Header, and now I want the child to contain the Description.
Can you show me an example of how to do this?
thanks
I'm working with the asp.net MVC panelbar. I have succeeded in creating the databound panelbaritems but I don't know how to create the child items.
I have one class
public class Item
{
public string Header{get;set;}
public string Description{get;set;}
public DateTime PostedDateTime{get;set;}
}
The panelbaritems contain the PostedDateTime and the Header, and now I want the child to contain the Description.
Can you show me an example of how to do this?
thanks
5 Answers, 1 is accepted
0
Hi David,
Basically when displaying child items you need a collection of objects which to display. In your case you have just a single item.
Anyway if you want to display child items and you use the BindTo method you should use the same overload as shown here (the example is from MVC TreeView but it is the same):
http://demos.telerik.com/aspnet-mvc/treeview/databindingtomodel
In your case it shoud be something like this:
All the best,
Petur Subev
the Telerik team
Basically when displaying child items you need a collection of objects which to display. In your case you have just a single item.
Anyway if you want to display child items and you use the BindTo method you should use the same overload as shown here (the example is from MVC TreeView but it is the same):
http://demos.telerik.com/aspnet-mvc/treeview/databindingtomodel
In your case it shoud be something like this:
.BindTo(
items
,( Kendo.Mvc.UI.Fluent.NavigationBindingFactory<PanelBarItem>mappings)=>{
mappings.For<item>(binding=>{
binding.ItemDataBound((pnaleBaritem, modelItem) =>
{
pnaleBaritem.Text = modelItem.Header;
}).Children(c=>c.Descriptions);//notice you need collection not just a single item
binding.ItemDataBound((pnaleBaritem, modelDescription) =>
{
pnaleBaritem.Text = model.DescriptionText;
});
});
})
All the best,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

freeTheCode
Top achievements
Rank 1
answered on 05 Feb 2013, 10:36 PM
This reply doesn't even answer the question asked and simply just leaves one wondering how to get simple questions answered.
The question is very clearly how to bind a PanelBar to a IEnumerable<someobject>,
1. Show someobject.property as the Panelbar header,
2. Show other properties of that object inside the expanded PanelBar as its Content e.g <ul> list or html with databinding to properties of someobject etc..
The recommended answer below which is to pass a collection of Descriptions is not even in line with the question posted and frankly makes no sense. Where is the collection of Descriptions in this viewmodel class?
public class Item
{
public string Header{get;set;}
public string Description{get;set;}
public DateTime PostedDateTime{get;set;}
}
This is a simple UI question that could be quickly achieved with any other framework, yet with Kendo, there is rarely good documentation or real life examples?
So let me try to rephrase the question. How does one create a databound template for the content of the Panelbar based on the item it is bound to?
If users are asking these basic questions, then clearly the documentation needs work, and the examples need to incorporate more real scenarios like described.
The question is very clearly how to bind a PanelBar to a IEnumerable<someobject>,
1. Show someobject.property as the Panelbar header,
2. Show other properties of that object inside the expanded PanelBar as its Content e.g <ul> list or html with databinding to properties of someobject etc..
The recommended answer below which is to pass a collection of Descriptions is not even in line with the question posted and frankly makes no sense. Where is the collection of Descriptions in this viewmodel class?
public class Item
{
public string Header{get;set;}
public string Description{get;set;}
public DateTime PostedDateTime{get;set;}
}
This is a simple UI question that could be quickly achieved with any other framework, yet with Kendo, there is rarely good documentation or real life examples?
So let me try to rephrase the question. How does one create a databound template for the content of the Panelbar based on the item it is bound to?
If users are asking these basic questions, then clearly the documentation needs work, and the examples need to incorporate more real scenarios like described.
0
Hello Charles,
Basically Template could be set when creating items through the Items method.
For example:
I hope this helps.
Kind Regards,
Petur Subev
the Telerik team
Basically Template could be set when creating items through the Items method.
For example:
.Items(panelbar =>
{
for
(
int
i = 0; i < Model.SomeCollection.Count; i++)
{
panelbar.Add().Text(
"My Header"
+ Model.SomeCollection[i].SomeProp).Content(@<text> Test template @Model.SomeCollection[i].SomeProp</text>);
}
}
I hope this helps.
Kind Regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0

Joe
Top achievements
Rank 1
answered on 01 Apr 2016, 06:46 PM
[quote]Petur Subev said:Hi David,
Basically when displaying child items you need a collection of objects which to display. In your case you have just a single item.
Anyway if you want to display child items and you use the BindTo method you should use the same overload as shown here (the example is from MVC TreeView but it is the same):
http://demos.telerik.com/aspnet-mvc/treeview/databindingtomodel
In your case it shoud be something like this:
All the best,
Petur Subev
the Telerik team
Basically when displaying child items you need a collection of objects which to display. In your case you have just a single item.
Anyway if you want to display child items and you use the BindTo method you should use the same overload as shown here (the example is from MVC TreeView but it is the same):
http://demos.telerik.com/aspnet-mvc/treeview/databindingtomodel
In your case it shoud be something like this:
.BindTo(
items
,( Kendo.Mvc.UI.Fluent.NavigationBindingFactory<PanelBarItem>mappings)=>{
mappings.For<item>(binding=>{
binding.ItemDataBound((pnaleBaritem, modelItem) =>
{
pnaleBaritem.Text = modelItem.Header;
}).Children(c=>c.Descriptions);//notice you need collection not just a single item
binding.ItemDataBound((pnaleBaritem, modelDescription) =>
{
pnaleBaritem.Text = model.DescriptionText;
});
});
})
All the best,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
[/quote]
I am using this to dynamically populate my panel bars, and it took me a while to modify it for my own needs since it's not very well explained, but I got it working. But I need to indent certain option in the children mapping, but creating the Text element with a bunch of to "indent" doesn't work. SO I assumed I could use the Content property. But damned if I could figure out how to populate it with dynamically generated HTML in the included binding methodology. Could someone tell me how I can take the model.DescriptionText, make it HTML and put it in the Content for that panel item?
0
Sounds like that you need a ClientTemplate?
Regards,
Hristo Valyavicharski
Telerik
Regards,
Hristo Valyavicharski
Telerik
Do you want to have your say when we set our development plans?
Do you want to know when a feature you care about is added or when a bug fixed?
Explore the
Telerik Feedback Portal
and vote to affect the priority of the items