Can the Picker Wheel have different values from labels?

Hi there,

Does anyone know if there’s any way I can set each entry in a picker wheel to have both a label and a hidden value.

For example, I’d display “January”, “February”, “March” etc. but the values would be 1,2,3.

Obviously I’d then want to be able to access those values to figure out what the selected option was.

Thanks in advance for any help.

Cheers,

Ian

Hi Ian,

When you do a “:getValues()” call on the picker row, you’ll get both a “value” and “index” property. The “value” is the label that you defined, and “index” is simply the number of the row that was created, so for a series of months, it would be 1 for January, 2 for February, etc. If this is your basic setup (a date picker), you can use that index.

If you need to associate other values (not like a basic index-to-row setup), I’d suggest just creating a relational lookup table, something like this:

[lua]

local pickerLookup = {

    { “A1”, “B1”, “C1”, “D1”, “E1” },

    {},  --column 2 lookup value

    {},  --column 3 lookup value

}

local values = pickerWheel:getValues()

local columnIndex1 = values[1].index

local lookupValue = pickerLookup[1][columnIndex1]

[/lua]

Hope this helps,

Brent

Thanks Brent - that’s very useful. It isn’t actually as simple as a date picker - I just used that example for simplicity’s sake here. The values in each picker wheel are created on the fly so different numbers depending on the specific situation. But - if I also create the lookup table on the fly it should work nicely.

Thanks for the quick response.

Ian

Hi Ian,

When you do a “:getValues()” call on the picker row, you’ll get both a “value” and “index” property. The “value” is the label that you defined, and “index” is simply the number of the row that was created, so for a series of months, it would be 1 for January, 2 for February, etc. If this is your basic setup (a date picker), you can use that index.

If you need to associate other values (not like a basic index-to-row setup), I’d suggest just creating a relational lookup table, something like this:

[lua]

local pickerLookup = {

    { “A1”, “B1”, “C1”, “D1”, “E1” },

    {},  --column 2 lookup value

    {},  --column 3 lookup value

}

local values = pickerWheel:getValues()

local columnIndex1 = values[1].index

local lookupValue = pickerLookup[1][columnIndex1]

[/lua]

Hope this helps,

Brent

Thanks Brent - that’s very useful. It isn’t actually as simple as a date picker - I just used that example for simplicity’s sake here. The values in each picker wheel are created on the fly so different numbers depending on the specific situation. But - if I also create the lookup table on the fly it should work nicely.

Thanks for the quick response.

Ian