skhye05 / nativescript-multi-select

Apache License 2.0
11 stars 6 forks source link

Feature Request: Single selection #15

Open picciama opened 4 years ago

picciama commented 4 years ago

Currently, there is no option to allow only a single selection. Specifically, what I'm looking for is to let the plugin automatically unselect the previously selected item once a new item is selected. Also I could not find a hacky way around it using the callback functions.

This feature would really complete the plugin because sometimes you only want a single selection without using a different plugin which looks and behaves differently. If this is also requested by other users, I consider doing it myself and create a pull request.

michaelsmedley commented 3 years ago

@picciama Did you manage to find a solution for this? I'm looking for a single select option for the same reasons you are and, while I can detect if there are more then 1 selectedItems, I can't seem to figure out how to alter/deselect/restrict any options based on this

picciama commented 3 years ago

@picciama Did you manage to find a solution for this? I'm looking for a single select option for the same reasons you are and, while I can detect if there are more then 1 selectedItems, I can't seem to figure out how to alter/deselect/restrict any options based on this

Hi @michaelsmedley, in my specific case, I only needed this for a small list that doesn't actually need the search functionality as it has only 7 entries fitting into the view. I simply used action from nativescript core like so:

import { action } from "@nativescript/core"

class Foo {
   select() {
      action(options_list).then((result) => {
         console.log(result);
      }
   }
}

For me that's working fine for now but if you want sth. more complex then I think you should checkout other packages. I'm actually going to abandon this package as it isn't maintained (which is a shame) but I have more pressing issues at the moment.

Maybe check out this package https://github.com/OPADA-Eng/ticnat-ns-plugins

michaelsmedley commented 3 years ago

Hi, thanks for the reply.

Like yourself, I went with a different approach to my issue. I had a few options but again it was only a few that I had to select from so using the plugin seemed a bit overkill.

Thanks for the other recommendation too, whilst it’s a bit too late to get into my current project I’ll look into it for future ones