This commit is contained in:
yumoqing 2024-05-06 18:26:21 +08:00
parent 6a23ff18b0
commit 88a34ba271
2 changed files with 17 additions and 2 deletions

View File

@ -48,8 +48,14 @@ bricks.DataRow = class extends bricks.HBox {
});
} else {
tools.push({
name:'update',
tip:'update current record',
icon:editable.update_icon || bricks_resource('imgs/update.png')
});
tools.push({
name:'delete',
tip:'delete current record',
icon:editable.delete_icon || bricks_resource('imgs/delete.png')
});
}
}
@ -74,11 +80,18 @@ bricks.DataRow = class extends bricks.HBox {
this.add_widget(w);
this.event_names = []
for(var i=0;i<tools.length;i++){
this.event_names.push(tools[i].name);
w.bind(tools[i].name, this.dispatch(tools[i].name));
if (tools[i].name != 'blankicon'){
this.event_names.push(tools[i].name);
w.bind(tools[i].name, this.my_dispatch(tools[i].name));
}
}
console.log('this.event_names=', this.event_names);
}
my_dispatch(e){
console.log('DataRow(): dispatch event', e);
this.dispatch(e);
}
build_fields(header){
for (var i=0;i<this.fields.length;i++){
var f = this.fields[i]

View File

@ -22,6 +22,7 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
dr.bind('update', this.update_record.bind(this, dr, record));
dr.bind('delete', this.delete_record.bind(this, dr, record));
dr.event_names.forEach(e => {
console.log('e=', e, 'record=', record);
dr.bind(e, this.record_event_handle.bind(this, e, record, dr, item));
});
} else {
@ -34,6 +35,7 @@ bricks.Tabular = class extends bricks.DynamicAccordion {
return dr;
}
record_event_handle(event_name, record, row, item){
console.log('event_name=', event_name, 'record=', record);
this.dispatch(event_name, record);
}
}