tabalinas / jsgrid

Lightweight Grid jQuery Plugin
http://js-grid.com
MIT License
1.53k stars 353 forks source link

Allow objects to be passed into SelectField #1400

Open unitedsoftwork opened 2 years ago

unitedsoftwork commented 2 years ago

With this little bit of code we can allow the select field to receive an object rather than just an integer, this is very useful for when a REST API sends nested data rather than just ID's that are references to the data.

e.g

with the field set up like so:

{
     name: "job",
     type: "select",
     items: [*some_array_of_choices*],
     valueField: "id",
     textField: "title",
     title: "Job",
 },

Rather than { "id": 1, "name": "John Doe", "job": 1 } we can now pass something like this { "id": 1, "name": "John Doe", "job": { "title": "Manager", "id": 1 } }

unitedsoftwork commented 2 years ago

ah yes. tests lol. The test has been written to describe the new functionality. If you go through with the PR i can update the docs to account for it.