Page 1 of 1

Disable unselect in DataTable

Posted: 29 Sep 2016, 04:49
by Ctrl-C
Is it possible to disable unselection in single select mode? Only unselect when other row selected.

Re: Disable unselect in DataTable

Posted: 29 Sep 2016, 20:58
by abarberi
If I am understanding you correctly... You want to force the user to have 1 row on the DataTable selected?

Re: Disable unselect in DataTable

Posted: 29 Sep 2016, 22:24
by Ctrl-C
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.

Re: Disable unselect in DataTable

Posted: 04 Nov 2016, 18:24
by loebe
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.

Re: Disable unselect in DataTable

Posted: 04 Nov 2016, 18:39
by loebe
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...

Re: Disable unselect in DataTable

Posted: 12 Nov 2016, 05:54
by Ctrl-C
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.

Re: Disable unselect in DataTable

Posted: 12 Nov 2016, 12:12
by cagatay.civici
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.

Re: Disable unselect in DataTable

Posted: 23 May 2020, 20:04
by Kanakdas
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.

Re: Disable unselect in DataTable

Posted: 09 Jul 2020, 14:33
by Kanakdas
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.