TreeList: load in expanded state if options.expanded is true
This commit is contained in:
parent
d5e2fcc1c2
commit
c301a73e38
1 changed files with 14 additions and 14 deletions
|
@ -209,16 +209,14 @@ Ox.TreeList = function(options, self) {
|
||||||
items = items || self.options.items;
|
items = items || self.options.items;
|
||||||
level = level || 0;
|
level = level || 0;
|
||||||
items.forEach(function(item, i) {
|
items.forEach(function(item, i) {
|
||||||
var item_ = Ox.extend({
|
if (item.items && self.options.expanded) {
|
||||||
level: level
|
item.expanded = true;
|
||||||
}, item, item.items
|
}
|
||||||
? {
|
var item_ = Ox.extend({level: level}, item, item.items ? {
|
||||||
items: item.expanded
|
items: item.expanded
|
||||||
? parseItems(item.items, level + 1)
|
? parseItems(item.items, level + 1)
|
||||||
: []
|
: []
|
||||||
}
|
} : {});
|
||||||
: {}
|
|
||||||
);
|
|
||||||
ret.push(item_);
|
ret.push(item_);
|
||||||
if (item.items) {
|
if (item.items) {
|
||||||
ret = ret.concat(item_.items);
|
ret = ret.concat(item_.items);
|
||||||
|
@ -255,13 +253,15 @@ Ox.TreeList = function(options, self) {
|
||||||
$img.attr({
|
$img.attr({
|
||||||
src: getIcon(item.id, expanded).attr('src')
|
src: getIcon(item.id, expanded).attr('src')
|
||||||
});
|
});
|
||||||
expanded
|
if (expanded) {
|
||||||
? that.$element.addItems(
|
that.$element.addItems(
|
||||||
pos + 1, parseItems(item.items, item.level + 1)
|
pos + 1, parseItems(item.items, item.level + 1)
|
||||||
)
|
);
|
||||||
: that.$element.removeItems(
|
} else {
|
||||||
|
that.$element.removeItems(
|
||||||
pos + 1, parseItems(item.items, item.level + 1).length
|
pos + 1, parseItems(item.items, item.level + 1).length
|
||||||
);
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleItems(data) {
|
function toggleItems(data) {
|
||||||
|
|
Loading…
Reference in a new issue