TreeList: load in expanded state if options.expanded is true

This commit is contained in:
rolux 2012-06-22 09:22:04 +02:00
parent d5e2fcc1c2
commit c301a73e38

View file

@ -209,16 +209,14 @@ Ox.TreeList = function(options, self) {
items = items || self.options.items;
level = level || 0;
items.forEach(function(item, i) {
var item_ = Ox.extend({
level: level
}, item, item.items
? {
items: item.expanded
? parseItems(item.items, level + 1)
: []
}
: {}
);
if (item.items && self.options.expanded) {
item.expanded = true;
}
var item_ = Ox.extend({level: level}, item, item.items ? {
items: item.expanded
? parseItems(item.items, level + 1)
: []
} : {});
ret.push(item_);
if (item.items) {
ret = ret.concat(item_.items);
@ -255,13 +253,15 @@ Ox.TreeList = function(options, self) {
$img.attr({
src: getIcon(item.id, expanded).attr('src')
});
expanded
? that.$element.addItems(
if (expanded) {
that.$element.addItems(
pos + 1, parseItems(item.items, item.level + 1)
)
: that.$element.removeItems(
);
} else {
that.$element.removeItems(
pos + 1, parseItems(item.items, item.level + 1).length
);
}
}
function toggleItems(data) {