src/app/shared/models/cd-table-selection.ts
Properties |
Methods |
constructor()
|
hasMultiSelection |
Type : boolean
|
hasSelection |
Type : boolean
|
hasSingleSelection |
Type : boolean
|
selected |
Type : any[]
|
Default value : []
|
first |
first()
|
Get the first selected row.
Returns :
any
|
update |
update()
|
Recalculate the variables based on the current number of selected rows.
Returns :
void
|
export class CdTableSelection {
selected: any[] = [];
hasMultiSelection: boolean;
hasSingleSelection: boolean;
hasSelection: boolean;
constructor() {
this.update();
}
/**
* Recalculate the variables based on the current number
* of selected rows.
*/
update() {
this.hasSelection = this.selected.length > 0;
this.hasSingleSelection = this.selected.length === 1;
this.hasMultiSelection = this.selected.length > 1;
}
/**
* Get the first selected row.
* @return {any | null}
*/
first() {
return this.hasSelection ? this.selected[0] : null;
}
}