static void lookup(FormStringControl _ctrl)
{
SysTableLookup sysTableLookup =
SysTableLookup::newParameters(tablenum(UtilidElements), _ctrl);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR, typeQBR;
;
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));
queryBuildDataSource = query.addDataSource(tablenum(UtilidElements));
typeQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, recordType));
typeQBR.value(SysQuery::value(UtilElementType::Table));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
A livello di class declaration dichiariamo una variabile che conterrà l'id della tabella selezionata:
public class FormRun extends ObjectRun
{
TableId TableId;
}
Questa variabile verrà settata nel modified field del controllo "Tables"
public boolean modified()
{
boolean ret;
ret = super();
TableId = TableName2Id(this.text());
return ret;
}
Scriviamo a questo punto il metodo lookup del controllo "Fields"
public void lookup()
{
SysTableLookup sysTableLookup =
SysTableLookup::newParameters(tablenum(UtilidElements), this);
Query query = new Query();
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange nameQBR, typeQBR;
;
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Name));
sysTableLookup.addLookupfield(fieldnum(UtilidElements, Id));
queryBuildDataSource = query.addDataSource(tablenum(UtilidElements));
nameQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements,
ParentId));
nameQBR.value(queryValue(TableId));
typeQBR = queryBuildDataSource.addRange(fieldnum(UtilidElements, recordType));
typeQBR.value(SysQuery::value(UtilElementType::TableField));
sysTableLookup.parmQuery(query);
sysTableLookup.performFormLookup();
}
Possiamo verificare il funzionamento del form selezionando "CustTable"
Nessun commento:
Posta un commento