This is a migrated thread and some comments may be shown as answers.

Panel bar load content from clicked item

2 Answers 267 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 22 Aug 2013, 02:05 PM
Hello,

Is it possible to build a panel bar where the content is a grid of items retrieved by an ajax call ?
it could come from loading a view. How would you go about building something like this ?

2 Answers, 1 is accepted

Sort by
0
Shaun
Top achievements
Rank 1
answered on 23 Aug 2013, 08:50 AM
ok, I figured out how to add the grid.
Now I need a way to pass an id to the grid. The data obviously depends on this ID. 
I can add this id as the content of the panel bar item on the initial data bind.

Then I can have an on select method which looks like this :

function onSelectPanelBar(e) {
    var id = parseInt($(e.item.innerHTML)[1].innerHTML, 10);
    if (id > 0) {
        $("#instancesPanelBar").data("kendoPanelBar").append({
            text: "extra",
            contentUrl: "/templates/TemplateRepositoryGrid/" + id
        })
    }
}

this code works but of course it creates another item which is not what I want. I need to replace the content of the clicked panel bar item with the content that comes from that URL. How can I do this ? Is there a better way of doing this ?

For now, until I figure out a way to do this, I will simply add the contentUrl at the time of initial binding of the PanelBar. I am not happy with this approach however because it means all the data will be loaded in one go rather than when you actually select something. Hopefully someone can shed some light on this.
0
Petur Subev
Telerik team
answered on 26 Aug 2013, 11:24 AM
Hello Stuart,

The panelbar cannot send extra paramters to the server when reloading a pane. However you mentioned that you are using a Grid to display the data.

Using the data function of the read config of the Grid's dataSource you can send that ID to the server.

http://docs.kendoui.com/api/framework/datasource#configuration-transport.read.data

I hope this helps.

Kind Regards,
Petur Subev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
PanelBar
Asked by
Shaun
Top achievements
Rank 1
Answers by
Shaun
Top achievements
Rank 1
Petur Subev
Telerik team
Share this question
or