Delete dependent event.
Delete dependent event.
kaustubh.agrawal2000
Posts: 88Questions: 39Answers: 2
in Editor
Is it possible to delete a dependent event before adding one ??
OR
is it possible to execute the dependent callback only once ..
This discussion has been closed.
Answers
Currently no - the
dependent()
method will permanently add a listener to that field.What is it you need to do?
Allan
@allan @colin
this an issue if you only want the dependency when a new record is being created not when you edit an existing one.
I have implemented the following code. Whenever I create a new record first, "dependent" works fine. The only problem is: If I edit the new or any other existing record later on the "dependency" is still there but that is undesired.
I only get the desired result for editing if I didn't create a new record before. I really need to be able to delete the "dependent" event listener programmatically. Is there any way to get around this?
I resolved it myself based on @allan's comments in a different thread and a look at Editor's really abstract source code ...
This line kills the dependent event listener:
@vincmeister @kaustubh.agrawal2000 thanks for asking those questions. Hope this helps you guys, too.
This is the thread of @vincmeister I am referring to above.
https://datatables.net/forums/discussion/46843/how-to-disable-editor-dependent-on-action-edit#latest
Hi,
Thanks for posting back with your findings. I must admit I hadn't considered the case when you might want
dependent
on a create form but not on an edit form.I've created a feature request for this in our bug tracker. Until that is developed, using the
off
method as you describe @rf1234 is the way to do it (since that is basically all theun-dependent
would do itself).Allan
@allan , thanks!
Just to give you the business background for this:
Creating a new record (here a loan contract) you want to preset some of the fields with what you've entered in other fields. Here: You want to preset the day of all following payments based on the first payment date. You enter the first payment date first and in a second step you can adjust the day for all future payments after the first payment.
Of course when opening the Edit form you don't want your saved future payments day
to get overwritten with the day of the first payment - and accidentally saved when making other changes.
Quick update on this - Editor 1.9 is going to have an
undependent()
method which can be used to remove dependencies added usingdependent()
.Allan