How can I combine the data from two or more columns into a "select" dropdown box?
How can I combine the data from two or more columns into a "select" dropdown box?
Dirk Finchley
Posts: 1Questions: 1Answers: 0
If I have a table called Customer keyed on "id" but I want to show the cust.first_name and cust.surname concatenated (with a space separator between them) so the user sees a sorted list of customer names alongside the customer ids? How can I achieve this?
This discussion has been closed.
Answers
you can easily do this if you use the php library that accompained with datables or you have to re-invent the wheel
I'm going to take field with type select as an example
basically you have to define your field with type select and pass an empty array first then use field api and invoke update method.
e.g
editor.field('test').update(loadJson("/your/api/url"));
the response from the server should be something like below your server side script should prepare the concatenated field name from your DB
{ label: "John Doe",value:"1" }
take note loadJson is a wrapper method/function of $.ajax function to get the JSON data from the server. I hope this make sense.
Please read the example carefully from the site it has a very good documentation just to start to get your feet wet. Good luck