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

DataTable Single Mode Selection doesn't unselect #783

Closed
ats17 opened this issue Aug 24, 2016 · 8 comments
Closed

DataTable Single Mode Selection doesn't unselect #783

ats17 opened this issue Aug 24, 2016 · 8 comments
Assignees
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Milestone

Comments

@ats17
Copy link

ats17 commented Aug 24, 2016

From [http://www.primefaces.org/primeng/#/datatableselection]: "In single mode, a row is selected on click event of a row. If the row is already selected then the row gets unselected."

Instead, clicking on a selected row simply fires another onRowSelect event. This behavior can be seen in the Showcase example at the link above.

@cagataycivici cagataycivici added the Status: Pending Review Issue or pull request is being reviewed by Core Team label Aug 25, 2016
@cagataycivici cagataycivici added this to the 1.0.0-beta.14 milestone Aug 25, 2016
@cagataycivici cagataycivici self-assigned this Aug 25, 2016
@cagataycivici cagataycivici added Type: Bug Issue contains a bug related to a specific component. Something about the component is not working and removed Status: Pending Review Issue or pull request is being reviewed by Core Team labels Aug 26, 2016
@nabeelbukhari
Copy link

nabeelbukhari commented Nov 20, 2016

Hi Guys,

I am still facing same issue in 1.0.0-rc.5. In my scenario, the selection mode is single and I have only one data item in table. Even same is not working in live examples on site.

http://www.primefaces.org/primeng/#/datatable/selection

Can you please test on it and revert. On selecting again, it still fires onRowSelect event.

Thanks,
Nabeel

@nabeelbukhari
Copy link

A workaround for same is to press Ctrl while selecting again and it will allow to deselect.

@praveens4all
Copy link

still am facing same issue onRowUnselect. its not firing. using 1.0.0-beta.17

@m00k
Copy link

m00k commented Dec 20, 2016

issue still exists with 1.1.0, can be observed on http://www.primefaces.org/primeng/#/datatable/selection. no unselect events are fired for mouse clicks, seems to work for touch though (tested with chrome devtools device emulation).

@MakhouT
Copy link

MakhouT commented Apr 19, 2017

You need to add [metaKeySelection]="false" property to the dataTable and then it should work. It also states that in the documentation under the section 'multiple'

@mugrufis
Copy link

mugrufis commented Sep 1, 2017

I have the same issue as mentioned above.
My table is working normally,
<p-dataTable selectionMode="single" [(selection)]="selectedUser" (onRowSelect)="onRowSelect($event)" (onRowUnselect)="onRowUnselect($event)" [value]="users" expandableRows="true" [editable]="true" [rowsPerPageOptions]= [5,10] [rows]="5" paginator="true">
It just does not unselect. So when I add the [metaKeySelection]="false" it unselects the row, BUT now I get a weird error on the console.

On selecting a row the first error that pops is TypeError: Cannot read property 'id' of undefined
Unselecting the row works fine.
Selecting the same row again the error now reads TypeError: Cannot read property 'id' of null

Any idea whats going wrong?

@lakerko
Copy link

lakerko commented Sep 6, 2017

@mugrufis thank you for the [metaKeySelection]="false", it helped me. I didn't have your TypeError problem though. One thing I have different from you is, that I don't use selection in a two way data binding, I only set the value.

But I wrap p-datatable in my own datatable component and heavily extend it, so I don't think I can help you:/ I just wanted to say thank you.

Edit: I just noticed that @MakhouT was the first one who gave the advice. So thank to you too :)

@emma11y
Copy link

emma11y commented Apr 21, 2021

I created a method to deselect a row programmatically after selecting a single row and it works fine.

@ViewChild(Table, { static: true }) public table: Table; private unSelectRows(): void { this.table._selection = null; this.table.selectionKeys = {}; this.table.selectionChange.emit(null); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Bug Issue contains a bug related to a specific component. Something about the component is not working
Projects
None yet
Development

No branches or pull requests

9 participants