Disable unselect in DataTable

UI Components for Angular
Post Reply
User avatar
Ctrl-C
Posts: 97
Joined: 29 Sep 2016, 04:21

29 Sep 2016, 04:49

Is it possible to disable unselection in single select mode? Only unselect when other row selected.

abarberi
Posts: 13
Joined: 28 Sep 2016, 21:40

29 Sep 2016, 20:58

If I am understanding you correctly... You want to force the user to have 1 row on the DataTable selected?

User avatar
Ctrl-C
Posts: 97
Joined: 29 Sep 2016, 04:21

29 Sep 2016, 22:24

Initially - no. But as soon as he selects any row he can only change the selection, not 'unselect'. Most data grids I know work this way. What's the point to unselect in single selection mode? Anyway, that could be optional setting. Another useful thing would be to make onSelect/UnselectRow event handler return a value allowing to cancel selection change.

loebe
Posts: 7
Joined: 02 Aug 2016, 20:05

04 Nov 2016, 18:24

Did you find a way? Same use case here!
Unfortunately the onRowUnselect event is fired before the row gets unselected. Therefore its not possible to reset the value as a workaround. I also suggest a property on the event to prevent the unselect action.

loebe
Posts: 7
Joined: 02 Aug 2016, 20:05

04 Nov 2016, 18:39

As I figured out, what I said before is not completely true. The selection is removed BEFORE the event gets fired. But on a reset, the angular change detection wont get it right. Resetting the selection in a setTimeout does work. But the row selction flickers in the UI. Not really nice...

User avatar
Ctrl-C
Posts: 97
Joined: 29 Sep 2016, 04:21

12 Nov 2016, 05:54

Ok. rc4 seems to fix this issue. But brings another one. Now you can only multi-select using ctrl-click. Would be nice to have it configurable so, I can either just click or ctrl-click.
Implementing shift-click to select multiple rows at a time would be very nice too.

cagatay.civici
Prime
Posts: 18616
Joined: 05 Jan 2009, 00:21
Location: Cybertron
Contact:

12 Nov 2016, 12:12

In mobile devices , it multi selects with tapping no cutely key. After 1.0 we plan to add an attribute to make this customizable as it seems there are different preferences.

Kanakdas
Posts: 6
Joined: 06 May 2020, 14:19

23 May 2020, 20:04

Is this possible to avoid unselection even using ctr+select. on load I keep first row selected then on every selection earlier selection gets cleared and that row gets selected.
But What if at any given time I want one row selected. My selection mode is single.

Kanakdas
Posts: 6
Joined: 06 May 2020, 14:19

09 Jul 2020, 14:33

ctrl+c Please elaborate on how did you able to achieve this. rowUnselect event gets fired even before onstart function called. I have to achieve this where ctrl + click should not unselect the row.

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 4 guests