allow for updating a treelist's data option
This commit is contained in:
parent
36a5f5a95f
commit
ad368fb819
1 changed files with 12 additions and 6 deletions
|
@ -34,7 +34,8 @@ Ox.TreeList = function(options, self) {
|
||||||
.options(options || {})
|
.options(options || {})
|
||||||
.update({
|
.update({
|
||||||
data: function() {
|
data: function() {
|
||||||
// ...
|
self.options.items = getItems();
|
||||||
|
self.$list.options({items: parseItems()});
|
||||||
},
|
},
|
||||||
selected: function() {
|
selected: function() {
|
||||||
//self.$list.options({selected: self.options.selected});
|
//self.$list.options({selected: self.options.selected});
|
||||||
|
@ -47,10 +48,7 @@ Ox.TreeList = function(options, self) {
|
||||||
});
|
});
|
||||||
|
|
||||||
if (self.options.data) {
|
if (self.options.data) {
|
||||||
self.options.items = [];
|
self.options.items = getItems();
|
||||||
Ox.sort(Object.keys(self.options.data)).forEach(function(key) {
|
|
||||||
self.options.items.push(parseData(key, self.options.data[key]));
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
that.setElement(
|
that.setElement(
|
||||||
|
@ -155,6 +153,14 @@ Ox.TreeList = function(options, self) {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getItems() {
|
||||||
|
var items = [];
|
||||||
|
Ox.sort(Object.keys(self.options.data)).forEach(function(key) {
|
||||||
|
items.push(parseData(key, self.options.data[key]));
|
||||||
|
});
|
||||||
|
return items;
|
||||||
|
}
|
||||||
|
|
||||||
function getParent(id, items) {
|
function getParent(id, items) {
|
||||||
var ret;
|
var ret;
|
||||||
Ox.forEach(items, function(item) {
|
Ox.forEach(items, function(item) {
|
||||||
|
@ -207,7 +213,7 @@ Ox.TreeList = function(options, self) {
|
||||||
level: level
|
level: level
|
||||||
}, item, item.items
|
}, item, item.items
|
||||||
? {
|
? {
|
||||||
items: !!item.expanded
|
items: item.expanded
|
||||||
? parseItems(item.items, level + 1)
|
? parseItems(item.items, level + 1)
|
||||||
: []
|
: []
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue