问题
I Have created a dialog in a class, the dialog method is as below
static void dialog(Args _args)
{
Dialog dialog;
DialogField dialogFieldCurrentState;
DialogField dialogFieldNewState;
CustInvoiceTable custInvoiceTable;
;
custInvoiceTable = _args.record();
dialog = new Dialog("Change State");
dialogFieldCurrentState = dialog.addField(TypeID(State_LT),"Current State: ");
dialogFieldCurrentState.value(custInvoiceTable.State);
dialogFieldCurrentState.enabled(false);
dialogFieldNewState = dialog.addField(TypeID(State_LT),"New State: ");
if (dialog.run())
{
custInvoiceTable.State = dialogFieldNewState.value();
}
}
in my dialog there are two fileds Current State
and New State
.Now when i select the New State
the list of all
states is displayed(irrespective of country) which i dont want. Only the states respective of country has to be shown
in the lookup
. I need to make use of a filter something like e.g. while select while select AddressState
where addressState.CountryRegionId == custInvoiceTable.CountryRegionId;
so that only states which
are related to a country is shown.
State_LT here is an string EDT (where i put in the relation of State_LT) State_LT == AddressState.StateId
IN AdressState there is a method lookupStateId(), How to call it from a dialog(code above) ?
回答1:
I am answering to your last question: "IN AdressState THERE IS A METHOD lookupStateId(), HOW TO CALL IT FROM A DIALOG(code above) ?" - by the way writing in capital letters doesn't help people understand your point better.
It is not clear why your dialog
is a static method, anyway you'd need the following.
Let's say your ClassDeclaration looks something like this:
class TestClass1 extends RunBase
{
Dialog dialog;
DialogField dialogFieldCurrentState;
DialogField dialogFieldNewState;
// etcetera
}
Your dialog
is something like this:
public Object dialog()
{
;
dialog = super();
dialogFieldCurrentState = dialog.addField(TypeID(AddressStateId),"Current State: ");
dialogFieldCurrentState.enabled(false);
dialogFieldNewState = dialog.addField(TypeID(AddressStateId),"New State: ");
dialogFieldNewState.lookupButton(FormLookupButton::Always); // If needed
return dialog;
}
To implement a lookup the way you want it you need to do two things. First, open the dialog, right click on the New State, click Setup, and check the control's System Name. If for example it is Fld2_1 then you need to create the following method:
void fld2_1_lookup()
{
Object control = dialog.formRun().controlCallingMethod();
;
AddressState::lookupStateId(control, dialogFieldNewState.value());
}
Second, it is necessary to override the following method:
public void dialogPostRun(DialogRunbase _dialog)
{
super(_dialog);
_dialog.dialogForm().formRun().controlMethodOverload(true);
_dialog.dialogForm().formRun().controlMethodOverloadObject(this);
}
That should do the trick. I haven't done it for a while but I don't think I forgot something.
回答2:
Example of looking up customer in dialog:
For example, to have a customer choice dropdown in the dialog,
In report class declaration method --->
DialogField CustomerDlg; CustAccount customer;
- In the reports dialog method: ----->
dialog.addGroup("Customer"); CustomerDlg = dialog.addField(typeid(CustAccount)); CustomerDlg.value(customer);
- In the getFromDialog method: ---->
... customer = CustomerDlg.value();
来源:https://stackoverflow.com/questions/5632147/filter-look-up-in-dialog