This commit is contained in:
yumoqing 2024-05-14 17:47:24 +08:00
parent e39214e606
commit f2cfc34aaf

View File

@ -166,6 +166,20 @@ bricks.Tree = class extends bricks.VScrollPanel {
this.create_node_children(this, this.opts.data); this.create_node_children(this, this.opts.data);
} }
create_toolbar(){ create_toolbar(){
var toolbar = bricks.extend({}, this.toolbar);
var tools = [];
toolbar.tools.forEach(f => tools.push(f));
if (this.editable){
tools.push({icon:bricks_resource('imgs/add.png'), name:'add'});
tools.push({icon:bricks_resource('imgs/update.png'), name:'update'});
tools.push({icon:bricks_resource('imgs/delete.png'), name:'delete'});
}
toolbar.tools = tools;
this.toolbar_w = new bricks.IconBar(toolbar);
this.add_widget(this.toolbar_w);
this.toolbar_w.bind('add', this.add_new_node.bind(this));
this.toolbar_w.bind('delete', this.delete.bind(this));
this.toolbar_w.bind('update', this.update_node.bind(this));
} }
async get_children_data(node){ async get_children_data(node){
var jcall = bricks.jcall; var jcall = bricks.jcall;
@ -186,15 +200,22 @@ bricks.Tree = class extends bricks.VScrollPanel {
} }
} }
node_click_handle(node, event){ node_click_handle(node, event){
if (this.selected_node){ if (this.selected_node == node){
this.selected_node.selected(false); this.selected_node.selected(false);
this.selected_node = node;
} else {
if (this.selected_node){
this.selected_node.selected(false);
}
this.selected_node = node;
node.selected(true);
this.dispatch('node_selected', node);
} }
this.selected_node = node;
node.selected(true);
this.dispatch('node_click', node);
} }
} }
/*
在数控件中提供增删改能力
*/
bricks. EditableTree = class extends bricks.Tree { bricks. EditableTree = class extends bricks.Tree {
/* /*
{ {