allow extension to select row in declarative table (#15703)

* allow extension to select row in declarative table

* pr comments

* use proper type for the event.

* update event arg
This commit is contained in:
Alan Ren
2021-06-15 15:41:37 -07:00
committed by GitHub
parent 24cd2106a1
commit a8f3d97f59
3 changed files with 45 additions and 9 deletions

View File

@@ -1544,7 +1544,7 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara
super(proxy, handle, ModelComponentTypes.DeclarativeTable, id, logService);
this.properties = {};
this._emitterMap.set(ComponentEventType.onDidChange, new Emitter<any>());
this._emitterMap.set(ComponentEventType.onDidClick, new Emitter<any>());
this._emitterMap.set(ComponentEventType.onSelectedRowChanged, new Emitter<azdata.DeclarativeTableRowSelectedEvent>());
}
@@ -1581,8 +1581,8 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara
return emitter && emitter.event;
}
public get onRowSelected(): vscode.Event<any> {
let emitter = this._emitterMap.get(ComponentEventType.onDidClick);
public get onRowSelected(): vscode.Event<azdata.DeclarativeTableRowSelectedEvent> {
let emitter = this._emitterMap.get(ComponentEventType.onSelectedRowChanged);
return emitter && emitter.event;
}
@@ -1602,6 +1602,14 @@ class DeclarativeTableWrapper extends ComponentWrapper implements azdata.Declara
this._proxy.$doAction(this._handle, this._id, ModelViewAction.Filter, rowIndexes);
}
public get selectedRow(): number {
return this.properties['selectedRow'] ?? -1;
}
public set selectedRow(v: number) {
this.setProperty('selectedRow', v);
}
public toComponentShape(): IComponentShape {
// Overridden to ensure we send the correct properties mapping.
return <IComponentShape>{