Need index of selected value for dropdown column type
Can i get the index of selected value of column type dropdown/autocomplete along with value in any of the events?
For example:
columns:[
{
type: 'dropdown',
source: [ 'Apples','Bananas','Carrots','Oranges','Cheese','Pears' ]
},
...
...
}
So if selected source value from dropdown is 'Carrots', it should also return index of the item as '2'.
In this case, currently i can only get 'Carrots' in onchange and onafterchanges events.
You can use a list of key-value objects as the source
[
{id: 1, name: 'Apples'},
{id: 2, name: 'Bananas'},
{id: 3, name: 'Carrots'},
{id: 4, name: 'Oranges'},
{id: 5, name: 'Cheese'},
{id: 6, name: 'Pears'}
]
The row information will contain the id instead of the text
@alfr3dosv Thanks for the help. I didn't know that it is possible to supply with array of objects.
You can try to get back using: table.options.columns[0].source.indexOf(yourValue);
But I imagine the K => V dropdown would do a better job.