用户要求在执行某个动作之前弹出一个对话框,让他选择一些供应商,只针对这些供应商去做动作,一下就会想到用Dialog这个类去做,于是写出如下代码:

static void dialogDemo(Args _args)
{
Dialog dialog = new Dialog();
DialogField dialogField;
VendAccount vendAccount;
boolean retValue;
;
dialogField = dialog.addField(typeId(VendAccount));
retValue = dialog.run();
if(retValue)
{
vendAccount = dialogField.value();
//do something else

}
}
一切都看似完美,但是有个问题,只能选择一个供应商,用户要求的是选择多个供应商,控件的replaceOnLookup属性是用来控制这个的,但是dialogField没有这个方法,咋办?添上。
在类DialogField上添加方法replaceOnLookup,如下所示:
在类DialogField上添加方法replaceOnLookup,如下所示:

void replaceOnLookup(boolean r)
{
str name;
// If properties exists then we are on server
if (properties)
{
name = #PropertyReplaceonlookup;
if (! properties.exists(name))
properties.add(name,true);
properties.value(name,r);
}
else
this.fieldControl().replaceOnLookup(r);
}
修改一下unpack方法,加上我们新增的属性
case #PropertyReplaceonlookup:
this.replaceOnLookup(unpackedProperties.valueIndex(i));
break;
this.replaceOnLookup(unpackedProperties.valueIndex(i));
break;
这样就可以调用这个方法来改变控件的属性了。

static void dialogDemo(Args _args)
{
Dialog dialog = new Dialog();
DialogField dialogField;
VendAccount vendAccount;
boolean retValue;
;
dialogField = dialog.addField(typeId(VendAccount));
dialogField.replaceOnLookup(false);
retValue = dialog.run();
if(retValue)
{
vendAccount = dialogField.value();
//do something else

}
}
效果如下图所示:


没有评论:
发表评论