#82 multiselection UI for datatable

This commit is contained in:
Denys Vuika
2016-05-20 13:30:11 +01:00
parent 4e9deac9ed
commit 58f7429f25
7 changed files with 70 additions and 6 deletions

View File

@@ -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://');
}