Skip to content
This repository has been archived by the owner on Jan 5, 2023. It is now read-only.

Commit

Permalink
selected row fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
ackava committed Jul 16, 2020
1 parent 0a0a709 commit 6a284ab
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/samples/database/web-sql/WebSqlViewModel.ts
Expand Up @@ -10,7 +10,7 @@ import RowEditor from "./row-editor/RowEditor";

export default class WebSqlViewModel extends AtomViewModel {

public rows: any[];
public rows: any[] = [];

public selectedRow: any = null;

Expand Down Expand Up @@ -41,9 +41,10 @@ export default class WebSqlViewModel extends AtomViewModel {
public async addRow() {
const model = await this.navigationService.openPage(RowEditor, { model: {} }) as any;
await this.database.transactionAsync(async (tx) => {
await tx.insertAsync("Customers", model);
const r = await tx.executeSqlAsync("SELECT * FROM Customers", []);
this.rows = r.rows;
const c = await tx.insertAsync("Customers", model);
model.id = c.insertId;
this.rows.add(model);
this.selectedRow = model;
});
}

Expand All @@ -65,6 +66,7 @@ export default class WebSqlViewModel extends AtomViewModel {
await tx.deleteAsync("Customers", filter);
const r = await tx.executeSqlAsync("SELECT * FROM Customers", []);
this.rows = r.rows;
this.selectedRow = null;
});
}
}

0 comments on commit 6a284ab

Please sign in to comment.