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

前端 未结 3 915
灰色年华
灰色年华 2021-01-18 11:49

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

相关标签:
3条回答
  • 2021-01-18 12:26

    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");
    
    0 讨论(0)
  • 2021-01-18 12:34

    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"]'));
    
    0 讨论(0)
  • 2021-01-18 12:49

    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
                });
    
    0 讨论(0)
提交回复
热议问题