-
First Item
- Sub Item 1
- Sub Item 2
- Sub Item 3
- Sub Item 4
-
Second Item
- Sub Item 1
- Sub Item 2
- Sub Item 3
- Sub Item 4
-
Third Item
- Sub Item 1
- Sub Item 2
- Sub Item 3
- Sub Item 4
-
Fourth Item
- Sub Item 1
- Sub Item 2
- Sub Item 3
- Sub Item 4
-
Fifth Item
- Sub Item 1
- Sub Item 2
- Sub Item 3
- Sub Item 4
- Description
- View Code
- Configuration (2)
- Methods (9)
- Events (5)
The PanelBar widget displays hierarchical data as a multi-level expandable panel bar. PanelBar structure can be defined statically in HTML or configured dynamically with the PanelBar API. Content for PanelBar items can also be easily loaded with Ajax simply by specifying the content URL.
Getting Started
Create a simple HTML hierarchical list of items
<ul id="panelbar">
<li>Item 1
<ul>
<li>Sub Item 1</li>
<li>Sub Item 2</li>
</ul>
<li>
<li>Item 2</li>
<li>Item with Content
<div>This is some PanelBar Item content</div>
</li>
</ul>Initialize Kendo PanelBar using jQuery selector
var panelBar = $("#panelBar").kendoPanelBar();Items in a PanelBar can optionally define in-line HTML content. To add content, simply place the HTML inside of a div. Text content outside of the div will be used as the Item's PanelBar text.
Loading Content with Ajax
While any valid technique for loading Ajax content can be used, PanelBar provides built-in support for asynchronously loading content from URLs. These URLs should return HTML fragments that can be loaded in the PanelBar item content area.
When PanelBar loads content with Ajax, it is cached so that subsequent expand/collapse actions do not re-trigger the Ajax request.
Loading PanelBar content asynchronously
<!-- HTML structure -->
<ul id="panelbar">
<li>Item 1
<ul>
<li>Sub Item 1</li>
</ul>
</li>
<li>Item 2</li>
<li>
Item with Dynamic Content
<div></div>
</li>
</ul> //JavaScript initialization and configuration
$(document).ready(function(){
$("#panelbar").kendoPanelBar({
contentUrls:[
null,
null,
"html-content-snippet.html"
]
});
});Customizing PanelBar Animations
By default, the PanelBar uses a slide animation to expand and reveal sub-items as the mouse hovers. Animations can be easily customized using configuration properties, changing the open and close animation style. A PanelBar can also be configured to only allow one panel to remain open at a time.
Changing PanelBar animation and expandMode behavior
$("#panelbar").kendoPanelBar({
animation: {
open : {effects: fadeIn}
},
expandMode: "single"
});Dynamically configuring PanelBar items
The PanelBar API provides several methods for dynamically adding or removing Items. To add items, provide the new item as a JSON object along with a reference item that will be used to determine the placement in the hierarchy.
A reference item is simply a target PanelBar Item HTML element that already exists in the PanelBar. Any valid jQuery selector can be used to obtain a reference to the target item. For examples, see the PanelBar API demos.
Removing an item only requires a reference to the target element that should be removed.
Dynamically add a new root PanelBar item
var pb = $("#panelbar").kendoPanelBar().data("kendoPanelBar");
pb.insertAfter(
{ text: "New PanelBar Item" },
pb.element.children("li:last")
);No code
-
append(item, referenceItem)Appends a PanelBar item in the specified referenceItemExample
panelBar.append( [{ text: "Item 1", content: "text" }, { text: "Item 2", contentUrl: "partialContent.html" }], referenceItem );Parameters
-
item: Selector - Target item, specified as a JSON object. You can pass item text, content or contentUrl here. Can handle an HTML string or array of such strings or JSON.
-
referenceItem: Item - A reference item to append the new item in
-
-
collapse(element, useAnimation)Collapses the specified PanelBar item/sExample
panelBar.collapse("#Item1");Parameters
-
element: Selector - Target item selector.
-
useAnimation: Boolean - Use this parameter to temporary disable the animation.
-
-
disable(element)Disables a PanelBar itemParameters
-
element: Selector - Target element
-
-
enable(element, enable)Enables/disables a PanelBar itemParameters
-
element: Selector - Target element
-
enable: Boolean - Desired state
-
-
expand(element, useAnimation)Expands the specified PanelBar item/sExample
panelBar.expand("#Item1");Parameters
-
element: Selector - Target item selector.
-
useAnimation: Boolean - Use this parameter to temporary disable the animation.
-
-
insertAfter(item, referenceItem)Inserts a PanelBar item after the specified referenceItemExample
panelBar.insertAfter( [{ text: "Item 1", content: "text" }, { text: "Item 2", contentUrl: "partialContent.html" }], referenceItem );Parameters
-
item: Selector - Target item, specified as a JSON object. You can pass item text, content or contentUrl here. Can handle an HTML string or array of such strings or JSON.
-
referenceItem: Item - A reference item to insert the new item after
-
-
insertBefore(item, referenceItem)Inserts a PanelBar item before the specified referenceItemExample
panelBar.insertBefore( [{ text: "Item 1", content: "text" }, { text: "Item 2", contentUrl: "partialContent.html" }], referenceItem );Parameters
-
item: Selector - Target item, specified as a JSON object. You can pass item text, content or contentUrl here. Can handle an HTML string or array of such strings or JSON.
-
referenceItem: Item - A reference item to insert the new item before
-
-
remove(element)Removes the specified PanelBar item/sExample
panelBar.remove("#Item1");Parameters
-
element: Selector - Target item selector.
-
-
select(element)Selects the specified PanelBar item/s. If called without arguments - returns the selected item.Example
panelBar.select("#Item1");Parameters
-
element: Selector - Target item selector.
-
Event data
-
item: Element - The collapsing item
Event data
-
item: Element - The selected item
-
item: Element - The loaded content element
Event data
-
xhr: jqXHR - The jqXHR object used to load the content
-
status: String - The returned status.
Event data
-
item: Element - The expanding item
Event data
-
item: Element - The selected item