Originally Posted by
Baidaly
Hello!
I agree with Geoffrey you shouldn't do this. Main reason it doesn't have sense because both of these mechanisms were created to communicate with a server. However, in most situations DirectMethod is called first but you can change it using Delays.
If can you provide example where you need this we can help you to find other ways to solve your problem.
I agree that it sounds weird to configure both direct event and direct method for the same event. The solution is related to my previous post here:
http://forums.ext.net/showthread.php...to-parent-page
Briefly, a grid column command loads another aspx page in an iframe window. I needed to render this new window into current page or the parent page depending on a parameter. If the calling page is already a window child of a parent page, then the new aspx page is to be rendered in parent page. if the calling page is not rendered in a window, then it is safe to render the new aspx page in the calling page. Daniil adviced to call direct method of the parent page to render the new aspx page in parent page instead of calling page. To sum up, I configured both a direct event and a direct method for the command column, and I set a URL parameter. If parameter value is "1", then direct event before event handler returns false and prevents direct event call, and parent pages direct method is called by command handler listener. If parameter value is "0", direct event before handler returns true and direct event is called. In this case, command handler listener does not call parent page's direct method.
See below simplified codes for direct event before event handler and command listener handler calling parent page direct method.
//to check whether to call direct method or not
function commandHandler(command) {
if (command == "myCommand") {
var renderChildToText = App.hiddenParameter.getValue();
var renderChildTo = parseInt(renderChildToText);
if (!isNaN(renderChildTo)) {
if (renderChildTo == 1) { //call direct method of parent page
if (parent.App.direct != null) {
if (parent.App.direct.myDirectMethod != null) {
parent.App.direct.myDirectMethod();
}
}
}
}
}
}
//to prevent direct event call if hiddden parameter value equals 1
function directEventBeforeHandler() {
var renderChildToText = App.hiddenParameter.getValue();
var renderChildTo = parseInt(renderChildToText);
if (!isNaN(renderChildTo)) {
if (renderChildTo == 1) {
return false;
}
else { //render to current form
return true;
}
}
}
Do you think there is a safer way to do this? Thank you.