Hello, basically the user need to select an option from a "select" input field. When he does that, another select with the same set of options should appear. I'm facing two problems:
- datatables get the data from a JSON. The Editor populates the select with the available options that it gets from the same JSON. This is achieved by simply giving to the select the same name of the JSON "options" node. Here follows a snippet of the end of the JSON, to clarify.
"options": {
"descrizione.UFF_INT": [
{
"value": "0",
"label": "-"
},
{
"value": "3",
"label": "Ufficio Interno"
},
{
"value": "4",
"label": "Ufficio Acquisti"
}
]
This is a snippet of the editor field configuration:
fields: [{
label: "Uffici Interessati:",
name: "descrizione.UFF_INT",
type: "select"
}
I tried to implement the editor.add but I'm not allowed to give to the new select field the same name that I gave to the first select (descrizione.UFF_INT). Thus I need to populate the array using an ajax call. So first question, is there a way to add a new field and keep using the options list provided by the JSON? I also tried to use this name - descrizione.UFF_INT[ ] - because that's the way you create an array of fields in HTML, but datatables doesn't seems to recognise and give value to this nomenclature.
- I'm using the add() api to add the new field. It seems to work but the field doesn't appear. Here follow a snippet of the code:
editor.on('open', function () {
$('.ui_add_remove div select').on( 'change', function () {
//alert($(this).attr('id'));
editor.add({
label: "Ufficio Interno 2:",
name: "prova2"
});
});
});
I know for sure that it works, because the first time that I trigger the select, no js errors are showed, while the second time it (correctly) throw this error "Error adding field 'prova2'. A field already exists with this name". So something happens but the field doesn't show up.
Could someone help me? Thanks in advance!