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

Issue with PanelBar having a Grid as content

2 Answers 77 Views
PanelBar
This is a migrated thread and some comments may be shown as answers.
Shaun
Top achievements
Rank 1
Shaun asked on 26 Aug 2013, 10:59 AM
Hello,

I have a treeview populated with some data. 

When you click on a node, it fires an ajax request and populates a PanelBar with the content.
each panel bar item then fires another request when clicked to load more data into a grid.

The issue is that on each click on a panel bar item, only one ajax request should fire. 
So click on a node in tree, you see the panel bar, click on an item and one request fires for the grid.
Click on another item in the tree, click on panel bar and then 2 requests fire.
click a third time and we'll notice 3 requests firing.

Somehow there seems to be a relation between how many calls the panel bar triggers and how many items in the tree were clicked.
I attached a test project to demonstrate the issue. 

Any idea why more than 1 request is fired when clicking on a PanelBar item and what can  I do to stop it ?

2 Answers, 1 is accepted

Sort by
0
Accepted
Daniel
Telerik team
answered on 28 Aug 2013, 08:30 AM
Hello,

Multiple requests are being made because the panelbar is initialized each time without destroying the old one. You should either destroy the panelbar when it has already been initialized:

var panelBarElement = $("#instancesPanelBar"),
    panelBar = panelBarElement.data("kendoPanelBar");
if (panelBar) {
    panelBar.destroy();      
}
 
panelBarElement.kendoPanelBar({
    dataSource: dsGrid
});
or just replace its dataSource:
var panelBarElement = $("#instancesPanelBar"),
    panelBar = panelBarElement.data("kendoPanelBar");
if (panelBar) {
    panelBar.setOptions({ dataSource: dsGrid });
}
else {
    $("#instancesPanelBar").kendoPanelBar({
        dataSource: dsGrid
    });
}
Regards,
Daniel
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Shaun
Top achievements
Rank 1
answered on 28 Aug 2013, 09:12 AM
it worked fine.

Thank you Daniel
Tags
PanelBar
Asked by
Shaun
Top achievements
Rank 1
Answers by
Daniel
Telerik team
Shaun
Top achievements
Rank 1
Share this question
or