Lookups can be defined on the EDT, property "FormHelp".
see http://www.axaptapedia.com/index.php/Lookup_Form
Else, there can be an automatic or a manual lookup.
see http://www.axaptapedia.com/Lookups
Write your own lookup (override lookup method)
This is an example of an ItemId lookup:
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(InventTable), this);
Query query = new Query();
QueryBuildDataSource dataSource = query.addDataSource(tablenum(InventTable));
QueryBuildRange range = dataSource.addRange(fieldnum(InventTable, ADUSawingItemId));
;
range.value(SysQuery::valueNotEmptyString());
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemId));
sysTableLookup.addLookupfield(fieldnum(InventTable, ItemName));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Adding custom labels to the dropdown fields
After you add the field, you add the custom label:
public void lookup()
{
SysTableLookup sysTableLookup = SysTableLookup::newParameters(tablenum(ConfigTable), this);
Query query = new Query();
QueryBuildDataSource dataSource = query.addDataSource(tablenum(ConfigTable));
QueryBuildRange range = dataSource.addRange(fieldnum(ConfigTable, ItemId));
;
range.value(queryValue(aduSawingCodeItemId));
sysTableLookup.addLookupfield(fieldnum(ConfigTable, ConfigId));
sysTableLookup.setLabel("Field ConfigId");
sysTableLookup.addLookupfield(fieldnum(ConfigTable, Name));
sysTableLookup.setLabel("Field Name");
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Filtering CongfigId lookup
I encountered a situation where I had a form with
- an unbound StringEdit control of ExtendedDataType ItemId
- an unbound StringEdit control of ExtnededDataType ConfigId
The dropdown on the ConfigId seemed to always be filtered in such a way
that it always showed only the ConfigId's for the ItemId in the ItemId field.
After some debugging, I found out that it was because I had a method called itemId on my form.
Apparently, in the ConfigIdLookup form, the executeQuery of the ConfigTable datasource says:
void executeQuery()
{
QueryBuildDataSource qbds = this.query().dataSourceTable(tablenum(ConfigTable));
fieldId fieldId;
;
if(!ctrlTabPageConfig.isActivePage())
{
return;
}
fieldId = inventDimFormSetup.callerItemFieldId();
if (fieldId)
{
qbds.addDynalink(
fieldnum(ConfigTable,ItemId),
inventDimFormSetup.callerItemIdFormDatasource().cursor(),
fieldId);
}
else
{
qbds.addRange(fieldnum(ConfigTable,ItemId)).value(inventDimFormSetup.callerItemId());
}
super();
}
and inventDimFormSetup.callerItemId() is
ItemId callerItemId()
{
if (! callerHasItemId)
return '';
if (callerItemIdMethod)
return callingElement.args().caller().itemId(); else
return this.callerItemIdFormDatasource().cursor().(this.callerItemFieldId());
}
So, the ConfigIdLookup form effectively called my itemId method to filter it's ConfigTable datasource!
Abonneren op:
Reacties posten (Atom)
Geen opmerkingen:
Een reactie posten