Capture events from the default cancel button.

1
Hi everyone, My situation is like this: I want to receive the event when users click the default Close button on a Dataview form. In case of existed objects, this form is to view/change the object, It works well- I can receive the change. In second case, I create the object, do not commit and used this form to open it. When I open and then cancel, the Javascript function to captured the change is not invoked. After that, by tracking the value of object associated with the form, I see that its ID is set to 0, Json value is null. I guess that for a new object, when the form is closed, the object is deleted right away and therefore, no change is sent back to the widget. Do you have a way to capture this event, I mean when cancelling the form opening new object. Regards,
asked
3 answers
1

Have you tried replacing the standard Cancel button with your own custom microflow button?

In the microflow, perform a rollback action and a close form action, then you can also add any other actions you may want to the same microflow.

answered
0

This could be a solution. I did not try yet. However, I expect a way that make the widget independent as much as possible. If i follow this way, i have to change all the cancel buttons, and could have some unexpected consequence on other actions.

answered
0

Hi all, I am trying a solution in which I override mx.processor.rollback.

mxrollbackold=mx.processor.rollback;
mx.processor.rollback=function(args, scope){
var mxObject=args.mxobj;    
var ret= mxrollbackold.apply(this, arguments);   
mx.processor.objectPing(mxObject);
return ret; 
}

In this one, i always send a message to the widget about the change. This also means that for an existed object, when I open and cancel the object, the widget will received two notifications related to the object. When I track the JSon message in MendixRuntime, it seems that the "openPing" only works on client side.

It still works well on my widget so far. However, I not sure that if it can have bad influences on other widgets (like datagrid)?

Do you have any advice about this way?

Thanks,

answered