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 || {})
|
||||
.update({
|
||||
data: function() {
|
||||
// ...
|
||||
self.options.items = getItems();
|
||||
self.$list.options({items: parseItems()});
|
||||
},
|
||||
selected: function() {
|
||||
//self.$list.options({selected: self.options.selected});
|
||||
|
@ -47,10 +48,7 @@ Ox.TreeList = function(options, self) {
|
|||
});
|
||||
|
||||
if (self.options.data) {
|
||||
self.options.items = [];
|
||||
Ox.sort(Object.keys(self.options.data)).forEach(function(key) {
|
||||
self.options.items.push(parseData(key, self.options.data[key]));
|
||||
});
|
||||
self.options.items = getItems();
|
||||
}
|
||||
|
||||
that.setElement(
|
||||
|
@ -155,6 +153,14 @@ Ox.TreeList = function(options, self) {
|
|||
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) {
|
||||
var ret;
|
||||
Ox.forEach(items, function(item) {
|
||||
|
@ -207,7 +213,7 @@ Ox.TreeList = function(options, self) {
|
|||
level: level
|
||||
}, item, item.items
|
||||
? {
|
||||
items: !!item.expanded
|
||||
items: item.expanded
|
||||
? parseItems(item.items, level + 1)
|
||||
: []
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue