select2: double initialValue request?
select2: double initialValue request?
Belorta
Posts: 13Questions: 3Answers: 0
Hello,
I have an editor that's displayed on the page using the onPageDisplay function. Some of the fields are select2 objects using ajax as data source.
When the form is shown, I see 2 initialValue requests for each of the select2 fields ("http://localhost:53686/Registraties/getOptions/TYB?initialValue=true&value=%22%22"). Is this to be expected?
(Sorry, but I can't make this accessible online to debug...)
The form is shown as follows:
editor
.buttons({
label: "Save",
fn: function () { this.submit(); }
})
.create(1, true, {
focus: null
});
Example of a select2-field definition:
{
"label": "type behandeling",
"name": "TYB",
"type": "select2",
"opts": {
placeholder: '...',
ajax: {
dataType: "json",
url: '/Registraties/getOptions/TYB',
data: function (params) {
return {
productid: ProductID
};
},
processResults: function (data) {
return {
results: data
};
},
}
}
}
This discussion has been closed.
Answers
Additional question about the onPageDisplay method: is it possible that the bootstrap4 theme is ignored with this? For example: the input elements don't have the "form-control" class. Without the display option in the initialisation of the editor, they do have that class...
What is
onPageDisplay
? That isn't a DataTables event or method. Is something else triggering that?Regarding the double Ajax from the Select2 field - no I wouldn't expect to see a double request and I've not been able to reproduce that there. If you put a break point in the plug-in at the Ajax request, it might be possible to determine what is kicking it off each time.
Thanks,
Allan
I got the onPageDisplay function from https://editor.datatables.net/plug-ins/display-controller/editor.onPage ...
The double ajax call: I'll try to debug it a bit more and keep you informed...
About the doubje ajax call:while debugging, I found the following piece of code in dataTables.editor.js in the create function:
For each field, the ajax call (in editor.select2.js) is called once from the field.multiSet function, and once from the field.set function. Does this help you?
Yes, thank you. I'm not sure why I'm not seeing it, but that gives me somewhere to start experimenting. I'll get back to you once I've dug into it.
Allan
Hey Allan,
Any news about the double ajax queries, and the missing bootstrap4-classes?
Thanks!
Tom