5 Answers, 1 is accepted
You can specify class="t-state-active" on the LI element that you want to initialize expanded, it will force the PanelBar to initialize it open. Another way is to call the PanelBar expand() method, but it will happen later and more visible.
Kind regards,
Kamen Bundev
the Telerik team
Expand is called like this:
// with widget initialization
var
panelBar = $(
"#panelbar"
).kendoPanelBar().data(
"kendoPanelBar"
);
// or
// without widget initialization
var
panelBar = $(
"#panelbar"
).data(
"kendoPanelBar"
);
// get first item and expand
var
item = $(
"#panelbar .t-item:eq(0)"
);
panelBar.expand(item);
For more information and a demo, please refer to:
http://demos.kendoui.com/panelbar/api.html
All the best,
Dimo
the Telerik team
I also had the same need to default all nodes to expanded and found the examples/documentation unclear.
First I added, class="t-state-active t-state-selected" to all of my root li tags in the panel. This did not have the expected behavior of defaulting them to open.
The solution that I came up with was to create an each selector and use the index to open the tags. Not pretty but it works, a better solution is appreciated.
$(document).ready(function () {
$('#panelbar .t-state-active').each(function (index) {
var item = $("#panelbar .t-state-active:eq(" + index + ")");
panelBar.expand(item);
});
});
var panelBar = $("#panelbar").kendoPanelBar().css({ marginRight: "220px" }).data("kendoPanelBar");
var
dummy = $(
"#panelbar"
).kendoPanelBar();
but if you want to use API you must explicitly call data("kendoPanelBar");
var
panelBar = $(
"#panelbar"
).kendoPanelBar().data(
"kendoPanelBar"
);
otherwise you get error message when you call expand/collapse or some other functions. This sort of things are not pointed out in documentation.
another thing
in the configuration section of PanelBar widget is for example explained expandMode
expandMode: String(default: multiple)
but what are the other options. It is somehow logical that it would be single but it's not specified in configuration section.