primeng icon indicating copy to clipboard operation
primeng copied to clipboard

Datatable: disableSelection property for checkboxes

Open jlin21 opened this issue 10 years ago • 6 comments

How can I use the template directive to disable certain checkboxes?

For example, if the color field is equal to green, disable the checkbox or simply replace it with a "N/A".

jlin21 avatar Sep 14 '16 18:09 jlin21

+1 for that Feature.

I need to disable the checkboxes in the table as well. My current solution is to have to coulmns which are hidden or shown with an *ngIf.

<p-column selectionMode="multiple" *ngIf="isDisabled()"></p-column>

<p-column *ngIf="!isDisabled()"> <template let-row="rowData" pTemplate type="body"> <p-checkbox name="displayDisabledCheckboxes" [(ngModel)]="_ngModel_" value="_value_" disabled="true" binary="true"></p-checkbox> </template> </p-column>

severinkehding avatar Oct 06 '16 06:10 severinkehding

@severinkehding How did you get access to the individual row data in *ngIf="isDisabled()" for your work around?

kotojo avatar Jun 16 '17 12:06 kotojo

@kotojo perhaps i do not understand you question correctly but i'll access the row data with the [(ngModel)]="ngModel" binding as usual.

The checkbox is either editable or disable. If the user is eligible to edit the checkbox value the binding will obviously change the value. if he is not eligible the binding will show the given value. i simply hide or show the right html piece depending on the isDisabled() result.

severinkehding avatar Jun 20 '17 09:06 severinkehding

I have implemented disabling checkbox with condition like it

disable=true

Here is the repo to my implementation . https://github.com/sryara/primeng-webpack-datatable-checkbox-disable

Probably this might not be a ideal solution but works for basic requirement of conditional checkbox disable.

sryara avatar Aug 21 '17 03:08 sryara

+1 for this feature

xtoff avatar Oct 04 '17 14:10 xtoff

p-dataTable is deprecated and will be removed in favor of the new p-table (aka TurboTable) of 5.1.0 so closing the issue. Please try the new p-table once 5.1.0 is released.

cagataycivici avatar Jan 13 '18 22:01 cagataycivici