slightly improved treelist

This commit is contained in:
rolux 2012-04-09 10:41:06 +02:00
parent ffa8f1738a
commit baf0f72912

View file

@ -31,10 +31,7 @@ Ox.TreeList = function(options, self) {
selected: [],
width: 256
})
.options(options || {})
.bindEvent({
select: selectItem
});
.options(options || {});
if (self.options.data) {
self.options.items = [];
@ -62,10 +59,13 @@ Ox.TreeList = function(options, self) {
})
.bindEvent({
anyclick: clickItem,
select: selectItem,
toggle: toggleItems
})
);
self.options.selected.length && selectItem({ids: self.options.selected});
function clickItem(e) {
var $target = $(e.target),
$item, id, item;
@ -155,7 +155,6 @@ Ox.TreeList = function(options, self) {
}
function parseData(key, value) {
//Ox.Log('List', 'parseData', key, value)
var ret = {
expanded: false,
id: Ox.uid().toString(),
@ -208,7 +207,9 @@ Ox.TreeList = function(options, self) {
expanded: true,
ids: parents
});
self.$list.options({selected: data.ids})
}
function toggleItem(item, expanded) {
var $img, pos;
item.expanded = expanded;
@ -248,7 +249,9 @@ Ox.TreeList = function(options, self) {
if (key == 'data') {
// ...
} else if (key == 'selected') {
self.$list.options({selected: value});
//self.$list.options({selected: value});
selectItem({ids: value});
self.$list.scrollToSelection();
} else if (key == 'width') {
// ...
}