avoid dependency
avoid dependency
Hello allan
I am facing a problem on dependency ..
for example
editor.dependent('date', function(val, data, callback){
editor.field('name').set('10');
)};
for the example shown above...
when i change 'date' field i need to set value 10 to 'name' field..
But if already i have a data in that field.. That should show that value in that field when i open that editor forum.. not dependent value ..
because if we written any caluculation part ..
it will caluculate that value while opening forum so i need to change only value to 'name' field only when 'date' field changed...
so just i showed you an example..
i need to avoid first time dependency while opening editor forum and rest work for all iteration ...
regards
karthik.r
Agiliti
Replies
Hi Agiliti,
The
data
parameter that is passed in has the original values for the fields and also their current values (e.g.data.row.date
for the original value,data.values.date
for the current value). What you could do is check to see if those values are different from theval
parameter that is passed in and then use a simpleif
condition to decide if you need to do the update or not.Allan
hello allan ,
it works but when i switched to the same parameter after changed from another parameter to the same what i got value when poped up in a same iteration...
for example i have value 10-12-2017 in 'date' field.. when i selected to 20-12-2017 and then reverse back to 10-12-2017 it wont works....
so i am asking thier is any option that i can avoid first dependency when it pop up editore forum
now actually i am keeping a flag to set that flag after it opens and disables after editor forum closes ...
is thier any alternative methods for these problem
regards
karthik.r
Not really. The
dependent()
callback has to fire when the field is updated with the value to be edited (since it would need to take account of the fact that the value to be edited is unlikely to be the value that was previously edited).The only workaround I can think of would be to listen for the
change
event on the input element directly (i.e. don't usedependent()
). When Editor sets the value (i.e. when editing starts) it will send aneditor
property in the data object for the callback:Allan