Nativescript version of the html select


#1

Hello,

I found this : http://docs.nativescript.org/cookbook/ui/list-picker

but it doesn’t seem to work like the html select where I can have a value and text.

How would I do this in Nativescript?

Thanks!

Randy


#2

I’ve been binding an array to my list pickers and then using the selectedIndex property to get that value of the array.

something like:

let values = ['option 1', 'option 2', 'option 3']
listpicker = page.getViewById('MyListPicker');

let selectedValue = values[listpicker.selectedIndex];

#3

That makes a lot of sense. Thank You.


#4

Hi,
How can I get the tap event when the user selects an item. ??


#5

@Pete.K

Sir, any solution !!

I am able to get the index and item but.
when he scrolls the listpicker i want that item to be displayed in a label on same view.


#6

With an onItemTap listener on the listview, when you tap on a list item, the listener will be called, and as a parameter you will be able to retrieve the index of the item tapped. Then you can get the item by index from the array that you’ve initially bound to the listview, and display its information any way you like.

Not sure if I am making much sense, it’s early in the morning.


#7

hahhaa :smiley: Happy Morning sir,

thanks a lot for the response. I will give get back here once I give it a try.

Have a great day.