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

Add rowSelectable property to DataTable #6736

Closed
gregAnd opened this issue Oct 23, 2018 · 32 comments
Closed

Add rowSelectable property to DataTable #6736

gregAnd opened this issue Oct 23, 2018 · 32 comments
Assignees
Labels
Type: New Feature Issue contains a new feature or new component request
Milestone

Comments

@gregAnd
Copy link

gregAnd commented Oct 23, 2018

[x ] bug report => Search github for a similar issue or PR before submitting

I am facing a problem on PrimeNG TurboTable.

I started from the following example: https://www.primefaces.org/primeng/#/table/selection and more particularly from the Checkbox Selection example.

The only difference is that on some p-tableCheckbox I added a [disabled]="true"

<p-tableCheckbox [value]="rowData" [disabled]="rowData.color==='orange'">

disabled checkbox

This works very well if I select a disabled line it does not activate and can not be selected, but when I click on p-tableHeaderCheckbox all the lines are selected even the lines in disabled.

all selected

In addition, the selection also counts the lines in status disabled or it should only take lines with no status disabled I made an example on stackblitz : https://stackblitz.com/edit/angular-gnbsml?file=src%2Fapp%2Fapp.component.html

How to prevent tableHeaderCheckbox from also selecting disable lines?

Thank you in advance for your answers

@bomberblue07
Copy link

This issue persists in 7.0 and would help my users greatly if fixed please!

@ausshadu
Copy link

ausshadu commented Dec 6, 2018

+1
Please add this. It would be a great addition. We can have additional configuration options, something like this <p-table [selectDisabledRows]="true/false"></p-table> to indicate <p-tableHeaderCheckbox></p-tableHeaderCheckbox> not to select disabled rows.

@Merve7

@francovegini
Copy link

+1

10 similar comments
@falexandre
Copy link

+1

@jlwollinger-zz
Copy link

+1

@ghost
Copy link

ghost commented Apr 29, 2019

+1

@andersonbuzzi
Copy link

+1

@sidneibiz
Copy link

+1

@marcoshevaristo
Copy link

+1

@maxonweb
Copy link

maxonweb commented Jun 7, 2019

+1

@HieuTrinh83
Copy link

+1

@grozdanova
Copy link

+1

@yelhouti
Copy link
Contributor

+1

@yelhouti
Copy link
Contributor

A PR has been made to fix this, in the meantime it's available here: https://github.com/yelhouti/primeng/releases/download/8.0.2/primeng-8.0.3-SNAPSHOT.tgz

@cagataycivici cagataycivici added this to the 8.1.0 milestone Sep 24, 2019
@cagataycivici cagataycivici added the Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add label Sep 24, 2019
@cagataycivici cagataycivici modified the milestones: 8.0.4, 8.1.0 Oct 7, 2019
@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Type: Enhancement Issue contains an enhancement related to a specific component. Additional functionality has been add labels Oct 7, 2019
@cagataycivici cagataycivici modified the milestones: 8.1.0, 8.1.1 Oct 23, 2019
@yigitfindikli yigitfindikli modified the milestones: 8.1.1, 8.1.2 Oct 23, 2019
@kramar
Copy link

kramar commented Oct 29, 2019

Hi guys, can you please tell is there date when PR from @yelhouti plan to be merged?

@yelhouti
Copy link
Contributor

@kramar they are not planning to merge it, looking for a better alternative

@kramar
Copy link

kramar commented Oct 29, 2019

@yelhouti Got it, thank you.

@tytusplanck
Copy link

tytusplanck commented Dec 5, 2019

Any updates on this issue? I haven't been able to find a workaround and this is severely affecting our user experience when we use the <p-table>.

@morula
Copy link

morula commented Dec 9, 2019

The setting "pSelectableRowDisabled" should also be taken into account.

@jyoti1904
Copy link

any updates on this issue?

@hilfor
Copy link

hilfor commented Jan 12, 2020

+1

@hilfor
Copy link

hilfor commented Jan 13, 2020

A workaround that we are using is to have an additional "selected" list in the component and updating it with (onRowSelect)="rowSelected($event)" and (onRowUnselect)="rowUnselected($event)"

While on the row checkbox we have the following:

<p-tableCheckbox
   [value]="rowData['disabled'] ? {} : rowData"
   [disabled]="rowData['disabled']">
</p-tableCheckbox>

But this workaround will not mark the header checkbox (select all) in case all of the enabled rows were selected

@cagataycivici cagataycivici removed this from the 8.1.2 milestone Jan 23, 2020
@bhavan0
Copy link

bhavan0 commented Apr 30, 2020

A workaround that we are using is to have an additional "selected" list in the component and updating it with (onRowSelect)="rowSelected($event)" and (onRowUnselect)="rowUnselected($event)"

While on the row checkbox we have the following:

<p-tableCheckbox
   [value]="rowData['disabled'] ? {} : rowData"
   [disabled]="rowData['disabled']">
</p-tableCheckbox>

But this workaround will not mark the header checkbox (select all) in case all of the enabled rows were selected

Any update on when this feature will be introduced?
Or if any workaround is available currently without this drawback?

@ReinhardFreiler
Copy link

Hi,
is there going to be a solution anytime soon?

@JulianFarhi
Copy link

Hi,
Any updates on this issue?

@coffeeniac
Copy link
Contributor

Hi,
any solution anytime soon?

@drvive
Copy link

drvive commented Jul 30, 2021

Hi,
any update on this?

@guoshuke
Copy link

guoshuke commented Aug 6, 2021

waiting......

@larreadg
Copy link

larreadg commented Aug 21, 2021

Hi,
Any update?

@s0nnyhu
Copy link

s0nnyhu commented Dec 22, 2021

Hello, up

@mertsincan mertsincan added Type: New Feature Issue contains a new feature or new component request and removed Type: Bug Issue contains a bug related to a specific component. Something about the component is not working labels Dec 23, 2021
@mertsincan mertsincan changed the title Turbotable : p-tableHeaderCheckbox selects disabled lines Add rowSelectable property to DataTable Dec 23, 2021
@mertsincan mertsincan added this to the 13.0.4 milestone Dec 23, 2021
@mertsincan
Copy link
Member

Hi all,

You can use rowSelectable property for this issue.

<p-table [value]="products" [(selection)]="selectedProducts5" dataKey="code" responsiveLayout="scroll" [rowSelectable]="isRowSelectable">
    <ng-template pTemplate="header">
        <tr>
            <th style="width: 3rem">
                <p-tableHeaderCheckbox></p-tableHeaderCheckbox>
            </th>
            <th style="min-width:200px">Code</th>
            <th style="min-width:200px">Name</th>
            <th style="min-width:200px">Category</th>
            <th style="min-width:200px">Quantity</th>
        </tr>
    </ng-template>
    <ng-template pTemplate="body" let-product>
        <tr>
            <td>
                <p-tableCheckbox [value]="product" [disabled]="isOutOfStock(product)"></p-tableCheckbox>
            </td>
            <td>{{product.code}}</td>
            <td>{{product.name}}</td>
            <td>{{product.category}}</td>
            <td>{{product.quantity}}</td>
        </tr>
    </ng-template>
</p-table>
 isRowSelectable(event) {
        return !this.isOutOfStock(event.data);
    }

    isOutOfStock(data) {
        return data.inventoryStatus === 'OUTOFSTOCK';
    }

I added a new demo related to this.

Screen.Recording.2021-12-23.at.09.36.43.mov

Best Regards,

@alimdi
Copy link

alimdi commented Oct 10, 2024

Is it possible the have a row always selected, no matter what ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: New Feature Issue contains a new feature or new component request
Projects
None yet
Development

Successfully merging a pull request may close this issue.