mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-10-01 14:41:32 +00:00
#82 multiselection UI for datatable
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
import {
|
||||
Component,
|
||||
// NgZone,
|
||||
OnInit,
|
||||
Input,
|
||||
Output,
|
||||
@@ -46,12 +47,19 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
|
||||
@Input()
|
||||
data: DataTableAdapter;
|
||||
|
||||
@Input()
|
||||
multiselect: boolean = false;
|
||||
|
||||
@Output()
|
||||
rowClick: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
@Output()
|
||||
rowDblClick: EventEmitter<any> = new EventEmitter();
|
||||
|
||||
isSelectAllChecked: boolean = false;
|
||||
|
||||
constructor(/*private _ngZone?: NgZone*/) {}
|
||||
|
||||
ngOnInit() {
|
||||
if (this.data) {
|
||||
console.log(this.data);
|
||||
@@ -98,6 +106,26 @@ export class DataTableComponent implements OnInit, AfterViewChecked {
|
||||
}
|
||||
}
|
||||
|
||||
onSelectAllClick(e?) {
|
||||
if (e) {
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
this.isSelectAllChecked = !this.isSelectAllChecked;
|
||||
|
||||
if (this.multiselect) {
|
||||
let rows = this.data.getRows();
|
||||
for (let i = 0; i < rows.length; i++) {
|
||||
rows[i].isSelected = this.isSelectAllChecked;
|
||||
}
|
||||
/*
|
||||
this._ngZone.run(() => {
|
||||
this.data.getRows()[1].isSelected = true;
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
|
||||
isIconValue(row: DataRow, col: DataColumn) {
|
||||
return row.getValue(col.key).startsWith('material-icons://');
|
||||
}
|
||||
|
Reference in New Issue
Block a user