DataTables Editor 'select' Field Type

DataTables Editor 'select' Field Type

stevehartstevehart Posts: 9Questions: 2Answers: 0
edited January 2015 in Free community support

Let's say I have a field that I want to be a dropdown for selecting the name of a city.

I have a DataTables Editor field that is a 'select' type and is populated, for example, with these options:

{ label: 'London', value: '1' }
{ label: 'Paris', value: '2' }
{ label: 'New York', value: '3' }

Data is retrieved from the server and displayed in the table. There are 3 records for example:

{ cityName: 'London', cityId: '1' }
{ cityName: 'Paris', cityId: '2' }
{ cityName: 'New York', cityId: '3' }

When the data is retrieved and displayed in the table how do I tell DataTables Editor to default the 'select' field to be the 'cityId' value from the database? I.E. How to I set the 'selected' attribute for the option value that matches the 'cityId'?

Currently with the above scenario in both inline and main editing modes, the dropdown always defaults to the first value.

Answers

This discussion has been closed.