Question: I want to add a runtime control and override a lookup method of it.
Answer: I have created a tutorial on form that can be used for this purpose. The form adds a control at run time and override the lookup method of it at runtime.
The form can be downloaded from here.
Showing posts with label display methods. Show all posts
Showing posts with label display methods. Show all posts
Friday, July 17, 2009
Friday, August 31, 2007
Overriding method for a control in dialog (RunBase framework)
Scenario:
Can we have an overridden method in a dialog class. I can not use form as a dialog. I have to add a method in the dialog class. Like modified method of an EDT.
Answer:
Well it can be done. First you have to add a method dialogPostRun
public void dialogPostRun(DialogRunbase dialog)
{
;
dialog.dialogForm().formRun().controlMethodOverload(true);
dialog.dialogForm().formRun().controlMethodOverloadObject(this);
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this);
super(dialog);
}
This method actually allows the dialog form to override control method at runtime. Now we need the name of the control at runtine that needs the overriden method. You can get that using
print dialogCustId.name();
pause;
where dialogCustId is the EDT. let say the name returned at runtime is Fld3_1.
Now if you have to override lookup method of the EDT you can write the method like this
void Fld3_1_lookup()
{
//override lookup method here
}
If you need to override modified method
boolean Fld3_1_modified()
{
}
.
The modified method can also be accessed by overriding
public void dialogSelectCtrl()
{
}
in the runbase class. Just call
dialog.allowUpdateOnSelectCtrl(true);
in the dialog method.
You can also create a dialog form and pass it as the parameter in the dialog method of runbase class. you can find an example in tutorial_runbase class and form.
Can we have an overridden method in a dialog class. I can not use form as a dialog. I have to add a method in the dialog class. Like modified method of an EDT.
Answer:
Well it can be done. First you have to add a method dialogPostRun
public void dialogPostRun(DialogRunbase dialog)
{
;
dialog.dialogForm().formRun().controlMethodOverload(true);
dialog.dialogForm().formRun().controlMethodOverloadObject(this);
dialog.formRun().controlMethodOverload(true);
dialog.formRun().controlMethodOverloadObject(this);
super(dialog);
}
This method actually allows the dialog form to override control method at runtime. Now we need the name of the control at runtine that needs the overriden method. You can get that using
print dialogCustId.name();
pause;
where dialogCustId is the EDT. let say the name returned at runtime is Fld3_1.
Now if you have to override lookup method of the EDT you can write the method like this
void Fld3_1_lookup()
{
//override lookup method here
}
If you need to override modified method
boolean Fld3_1_modified()
{
}
.
The modified method can also be accessed by overriding
public void dialogSelectCtrl()
{
}
in the runbase class. Just call
dialog.allowUpdateOnSelectCtrl(true);
in the dialog method.
You can also create a dialog form and pass it as the parameter in the dialog method of runbase class. you can find an example in tutorial_runbase class and form.
Labels:
axapta,
dialog box,
display methods,
dynamics ax,
override,
runbase,
x++
Saturday, August 25, 2007
Display method in code
Scenario: Can i use display methods in X++ code. I mean if i have a display method getStatus() on table Vend. I can use it like vend.getStatus(). Is it a violation of best practice what are the pros and cons.
Answer: No, there is no performance penalty and no best practice warning is issued.
So you can go ahead and use the display methods in code.
The only difference from a non-display method is that you can actually use them in forms and reports.
Snippet:
Add as display method getStatus() in the CustTabl method list.
public display boolean getStatus()
{
return true;
}
Use this method in the field group and in the code simultaneously.
public void processCustomerStatus()
{
if (this.getStatus())
{
this.write();
}
else
{
info("Consider status");
}
}
Answer: No, there is no performance penalty and no best practice warning is issued.
So you can go ahead and use the display methods in code.
The only difference from a non-display method is that you can actually use them in forms and reports.
Snippet:
Add as display method getStatus() in the CustTabl method list.
public display boolean getStatus()
{
return true;
}
Use this method in the field group and in the code simultaneously.
public void processCustomerStatus()
{
if (this.getStatus())
{
this.write();
}
else
{
info("Consider status");
}
}
Labels:
axapta,
code,
display methods,
dynamics ax,
performance,
x++
Thursday, August 23, 2007
Filtering and Sorting in display methods
Scenario: Can we have sorting and filtering in display methods?
Answer: You can not have sorting or filtering in display methods.
Answer: You can not have sorting or filtering in display methods.
Labels:
axapta,
display methods,
dynamics ax,
filtering,
sortig,
x++
Subscribe to:
Posts (Atom)