bugfix
This commit is contained in:
parent
6a87994bdf
commit
6bb13d7702
@ -181,7 +181,7 @@ bricks.Tree = class extends bricks.VScrollPanel {
|
|||||||
this.add_widget(this.container);
|
this.add_widget(this.container);
|
||||||
this.data_id = null;
|
this.data_id = null;
|
||||||
if (this.opts.dataurl){
|
if (this.opts.dataurl){
|
||||||
this.params = opts.params || {};
|
this.params = options.params || {};
|
||||||
schedule_once(this.get_children_data.bind(this, this), 0.1);
|
schedule_once(this.get_children_data.bind(this, this), 0.1);
|
||||||
} else {
|
} else {
|
||||||
this.user_data = {
|
this.user_data = {
|
||||||
@ -190,7 +190,6 @@ bricks.Tree = class extends bricks.VScrollPanel {
|
|||||||
}
|
}
|
||||||
this.create_node_children(this, this.opts.data);
|
this.create_node_children(this, this.opts.data);
|
||||||
}
|
}
|
||||||
this.bind('node_selected',this.node_info_log.bind(this));
|
|
||||||
}
|
}
|
||||||
getValue(){
|
getValue(){
|
||||||
var v = this.user_data;
|
var v = this.user_data;
|
||||||
@ -267,6 +266,9 @@ bricks.Tree = class extends bricks.VScrollPanel {
|
|||||||
}
|
}
|
||||||
append_new_subnode(node, data){
|
append_new_subnode(node, data){
|
||||||
data.is_left = true;
|
data.is_left = true;
|
||||||
|
if (!node.user_data){
|
||||||
|
node.user_data = {};
|
||||||
|
}
|
||||||
if (!node.user_data.children){
|
if (!node.user_data.children){
|
||||||
node.user_data.children = [];
|
node.user_data.children = [];
|
||||||
}
|
}
|
||||||
@ -378,9 +380,14 @@ bricks.Tree = class extends bricks.VScrollPanel {
|
|||||||
|
|
||||||
async get_children_data(node){
|
async get_children_data(node){
|
||||||
var jcall = bricks.jcall;
|
var jcall = bricks.jcall;
|
||||||
|
var p = bricks.extend({}, this.params);
|
||||||
|
if (node != this){
|
||||||
|
p.id = node.user_data[this.idField];
|
||||||
|
}
|
||||||
|
console.log('params=', p);
|
||||||
var d = await jcall(this.opts.dataurl,{
|
var d = await jcall(this.opts.dataurl,{
|
||||||
method : this.opts.method || 'GET',
|
method : this.opts.method || 'GET',
|
||||||
params : node.params
|
params : p
|
||||||
})
|
})
|
||||||
if (d.length == 0){
|
if (d.length == 0){
|
||||||
node.is_leaf = true;
|
node.is_leaf = true;
|
||||||
@ -422,20 +429,11 @@ bricks.Tree = class extends bricks.VScrollPanel {
|
|||||||
var cb = event.target.bricks_widget;
|
var cb = event.target.bricks_widget;
|
||||||
var stat = cb.getValue().check;
|
var stat = cb.getValue().check;
|
||||||
node.user_data[this.checkField] = stat;
|
node.user_data[this.checkField] = stat;
|
||||||
|
if (stat){
|
||||||
console.log('value=', cb.getValue(), 'node=', node);
|
console.log('value=', cb.getValue(), 'node=', node);
|
||||||
|
}
|
||||||
this.dispatch('check_changed', node.user_data);
|
this.dispatch('check_changed', node.user_data);
|
||||||
}
|
}
|
||||||
node_info_log(event){
|
|
||||||
if (event.params.selected == false){
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
var node = event.params.node;
|
|
||||||
console.log('======node info========');
|
|
||||||
console.log('user_data=', node.user_data);
|
|
||||||
console.log('parent=', node.parent_node);
|
|
||||||
console.log('container=', node.container);
|
|
||||||
console.log('======node info end========');
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bricks.Factory.register('Tree', bricks.Tree);
|
bricks.Factory.register('Tree', bricks.Tree);
|
||||||
|
Loading…
Reference in New Issue
Block a user