is there a way to collapse all the panels of Kendo Panelbar, on an action?
Asked Answered
H

3

7

I am working on an app where i am adding panelbars (multiselection) using JSP Wrapper (which means no ID to each of the panels), and inside those have the grids.

The grids are storing data specific to the selected person, who are displayed as list items(images) on the top of the page.

What I want to do is that when user changes the selection of person, from the current selected to another, collapse all the panels of the kendo panelbar. This would help in reloading the data of the new person, because when the user will select/expand the panel to see the data, i would catch the event and reload the grid with a new Datasource, based on the selected person.

I hope I make sense here, but I am not sure how to collapse all the panels of the PanelBar.

Any Suggestions??

Hipbone answered 9/5, 2013 at 21:52 Comment(0)
E
13

If the id of your PanelBar is panel, do:

$("#panel").data("kendoPanelBar").collapse($("li", "#panelbar"));

or

var panelbar = $("#panelbar").data("kendoPanelBar");
panelbar.collapse($("li", panelbar.element));

i.e. we will collapse every li element under #panelbar.

EDIT: If you want to remove the selection, add:

$(".k-state-selected", panelbar.element).removeClass("k-state-selected");
Ecclesiastes answered 10/5, 2013 at 0:37 Comment(3)
Thanks! that did the trick:) but it leaves behind the last selected panel highlighted. Is there a way to remove that selection or highlighting?Hipbone
And if I want to collapse a specific panel (not all panels), how can I do it?Cheney
@Ralph, I think that this is a different question. Did you try to ask it as a new? This way you will have a broader audience and, likely, an answer much faster.Ecclesiastes
A
1

HTML

  <ul id="palettePanelBar">
            <li id="item1" class="k-state-active">
               <!--Some Data-->
            </li>
            <li id="item2">
               <!--Some Data for second item-->

            </li>
 </ul>

Javascript

 var panelBar = $("#palettePanelBar").data("kendoPanelBar");
    panelBar.expand($('[id^="item"]'));
Aristotelianism answered 9/9, 2014 at 4:34 Comment(0)
H
0

You can use this block to collapse all panel and as a bonus to the answer, you can expand only the selected after that in this way:

var panelBar =  $("#importCvPanelbar").data("kendoPanelBar");
            panelBar.collapse($("li"));// will collapse all panel item
            panelBar.bind("select", function(e) {
                var itemId = $(e.item)[0].id;

                panelBar.expand(itemId);// will expand the selected one
            });
Helico answered 9/1, 2017 at 12:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.