EDITOR. Is it possible when you are setting one field to use a value of other field(s)
EDITOR. Is it possible when you are setting one field to use a value of other field(s)

Hello, friends! I have a Select2 field, wich is dependent of values of the other feilds in this row. Select2 sends ajax to the server to obtain options to choose. I need the value of another field in this row, to form an url. Also i need to set Select2 multi option depending on value of some other field. Something like that:
...
fields: [
{label: 'Field1', name: 'Field1'},
{label: 'Field2', name: 'Field2'},
{
label: 'Field3',
name: 'Field3',
type: "select2",
opts: {
ajax: {
url: url + field1.val(),
type: "GET",
dataType: "json",
processResults: function (data) {
return {
results: $.map(data, function(obj) {
return { id: obj.ime, text: obj.ime };
})
};
}
};,
},
multiple: field2.val()=="Multi"?true:false,
}
}
],
...
How can I achive this? Please give me a hint.
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
You could do both of those when the editing begins, in the
initEdit
- there you'll have access to the data in the row (the third parameter) - you can remove the field and re-add it again as needed. This example here is similar - it's changing the type of the 'Office' field depending on the value in 'Position' field.Colin
Thank you, Colin, you are a lifesaver, as always. Works great!