mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-06-30 18:15:11 +00:00
#82 datatable api improvements
This commit is contained in:
parent
27692bb6b7
commit
da5600b4d1
@ -3,8 +3,13 @@
|
||||
</div>
|
||||
<div class="p-10">
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
|
||||
(click)="addRow()">
|
||||
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
|
||||
(click)="addRow()">
|
||||
Add row
|
||||
</button>
|
||||
<button
|
||||
class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect"
|
||||
(click)="replaceRows()">
|
||||
Replace rows
|
||||
</button>
|
||||
</div>
|
||||
|
@ -58,7 +58,7 @@ export class DataTableDemoComponent {
|
||||
]
|
||||
);
|
||||
|
||||
this.data.setSorting(new DataSorting('name', 'asc'));
|
||||
this.data.setSorting(new DataSorting('id', 'asc'));
|
||||
}
|
||||
|
||||
addRow() {
|
||||
@ -72,4 +72,15 @@ export class DataTableDemoComponent {
|
||||
this.data.getRows().push(row);
|
||||
this.data.sort();
|
||||
}
|
||||
|
||||
replaceRows() {
|
||||
let objects = [
|
||||
{id: 10, name: 'Name 10', createdBy: this._createdBy, icon: 'material-icons://face'},
|
||||
{id: 11, name: 'Name 11', createdBy: this._createdBy, icon: 'material-icons://language'},
|
||||
{id: 12, name: 'Name 12', createdBy: this._createdBy, icon: 'material-icons://pets'},
|
||||
{id: 13, name: 'Image 13', createdBy: this._createdBy, icon: this._imageUrl}
|
||||
];
|
||||
let rows = objects.map(obj => new ObjectDataRow(obj));
|
||||
this.data.setRows(rows);
|
||||
}
|
||||
}
|
||||
|
@ -18,7 +18,9 @@
|
||||
export interface DataTableAdapter {
|
||||
|
||||
getRows(): Array<DataRow>;
|
||||
setRows(rows: Array<DataRow>): void;
|
||||
getColumns(): Array<DataColumn>;
|
||||
setColumns(columns: Array<DataColumn>): void;
|
||||
getValue(row: DataRow, col: DataColumn): any;
|
||||
getSorting(): DataSorting;
|
||||
setSorting(sorting: DataSorting): void;
|
||||
|
@ -49,10 +49,19 @@ export class ObjectDataTableAdapter implements DataTableAdapter {
|
||||
return this._rows;
|
||||
}
|
||||
|
||||
setRows(rows: Array<DataRow>) {
|
||||
this._rows = rows || [];
|
||||
this.sort();
|
||||
}
|
||||
|
||||
getColumns(): Array<DataColumn> {
|
||||
return this._columns;
|
||||
}
|
||||
|
||||
setColumns(columns: Array<DataColumn>) {
|
||||
this._columns = columns || [];
|
||||
}
|
||||
|
||||
getValue(row: DataRow, col: DataColumn): any {
|
||||
return row.getValue(col.key);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user