understanding editor join json object elements to populate select list

understanding editor join json object elements to populate select list

matthewjmatthewj Posts: 39Questions: 2Answers: 0
edited March 2013 in Editor
Can anyone explain the format of json object which is part of editor json to populate select list in editor? For eg I am referring to the json in example: http://editor.datatables.net/release/DataTables/extras/Editor/examples/join.html
ie I couldn't understand the meaning of {
"value": "1",
"0": "1",
"label": "IT",
"1": "IT"
} as in below json which is a part of the below json. I understand that its for populating the select list in the example but what is "0": "1" and "1": "IT"

"dept": [
{
"value": "1",
"0": "1",
"label": "IT",
"1": "IT"
},
{
"value": "2",
"0": "2",
"label": "Sales",
"1": "Sales"
},

Replies

  • matthewjmatthewj Posts: 39Questions: 2Answers: 0
    Is there anyone who can explain this or point to a link which explains this?
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    The `0` and `1` are actually redundant and not used. That's an error in the SQL fetch, getting both array values and keys. Only the keys are needed.

    Allan
  • matthewjmatthewj Posts: 39Questions: 2Answers: 0
    Thanks Allan for the clarification. Now I understand that its redundant. Related to this: can we use any string for the nodes "value" and "label". ie, can we have { "someid": "2", "title":"Sales"} instead of { "value":"2", "label": "Sales"} ?
  • allanallan Posts: 61,438Questions: 1Answers: 10,052 Site admin
    Currently no - it is only label and value pairs which are supported at this time. I will be relaxing this constraint to allow functions in future as well, but to use a different set of parameters, you'd need to either make a small change to the Editor core or use a plug-in field type which does support the parameters you want.

    Allan
  • matthewjmatthewj Posts: 39Questions: 2Answers: 0
    Thanks Allan
This discussion has been closed.