Define select options only once in editor
Define select options only once in editor
Hello,
I have 8 select fields with the same 4 options. So I defindet the options 32 times. Is there a way to define the options only once and reuse them vor every select field? Actually my code looks like this:
var editor = new $.fn.dataTable.Editor( {
ajax: 'php/doodle_table1.php',
table: '#doodle_table1',
fields: [
{
"label": "Name:",
"name": "name"
},
{
"label": dateMsg,
"name": "termin1",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg2,
"name": "termin2",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg3,
"name": "termin3",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg4,
"name": "termin4",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg5,
"name": "termin5",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg6,
"name": "termin6",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg7,
"name": "termin7",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
},
{
"label": dateMsg8,
"name": "termin8",
"type": "select",
"options": [
{"label": "", "value": ""},
{"label": "ja", "value": "1"},
{"label": "nein", "value": "0"},
{"label": "vielleicht", "value": "vielleicht"}
]
}
]
} );
Thanks for your help, I really appreciate it!
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Sure - do this:
Then in the Editor configuration simply:
for all of them :-)
Allan
Thank you Allan!