Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disabled property to TableHeaderCheckbox #5761

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 8 additions & 5 deletions src/app/components/table/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2783,10 +2783,9 @@ export class TableCheckbox {
template: `
<div class="ui-chkbox ui-widget" (click)="onClick($event, cb.checked)">
<div class="ui-helper-hidden-accessible">
<input #cb type="checkbox" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="!dt.value || dt.value.length === 0">
<input #cb type="checkbox" [checked]="checked" (focus)="onFocus()" (blur)="onBlur()" [disabled]="isDisabled()">
</div>
<div #box [ngClass]="{'ui-chkbox-box ui-widget ui-state-default':true,
'ui-state-active':checked, 'ui-state-disabled': (!dt.value || dt.value.length === 0)}">
<div #box class="ui-chkbox-box ui-widget ui-state-default" [ngClass]="{'ui-state-active':checked, 'ui-state-disabled': isDisabled()}">
<span class="ui-chkbox-icon ui-clickable" [ngClass]="{'fa fa-check':checked}"></span>
</div>
</div>
Expand All @@ -2797,7 +2796,7 @@ export class TableHeaderCheckbox {
@ViewChild('box') boxViewChild: ElementRef;

checked: boolean;

@Input()
disabled: boolean;

selectionChangeSubscription: Subscription;
Expand All @@ -2819,7 +2818,7 @@ export class TableHeaderCheckbox {
}

onClick(event: Event, checked) {
if(this.dt.value && this.dt.value.length > 0) {
if (!this.isDisabled()) {
this.dt.toggleRowsWithCheckbox(event, !checked);
}

Expand Down Expand Up @@ -2848,6 +2847,10 @@ export class TableHeaderCheckbox {
const val = this.dt.filteredValue||this.dt.value;
return (val && val.length > 0 && this.dt.selection && this.dt.selection.length > 0 && this.dt.selection.length === val.length);
}

isDisabled() {
return this.disabled || !this.dt.value || !this.dt.value.length;
}

}

Expand Down