I have set optionsDatasource property in superior field using my custom collectiondatasource, so i can filter the lookup items. But when i add lookupAction to superior field, it seems like the lookup action is still using the main datasource “departmentDs”.
How to set optionsDatasource property in the lookupAction ?
<dsContext>
<datasource id="departmentDs"
class="id.irfani.democuba.entity.Department"
view="department-view"/>
<collectionDatasource id="superiorsDs"
class="id.irfani.democuba.entity.Department"
view="_minimal">
<query>
<![CDATA[select e from democuba$Department e
where e.departmentLevelNo > :ds$departmentDs.departmentLevelNo]]>
</query>
</collectionDatasource>
</dsContext>
<layout expand="windowActions"
spacing="true">
<fieldGroup id="fieldGroup"
datasource="departmentDs">
<column width="250px">
<field id="departmentNo"/>
<field id="departmentName"/>
<field id="departmentLevel"/>
<field id="departmentLevelNo"
visible="true"/>
<field id="superior" editable="false"
optionsDatasource="superiorsDs"/>
</column>
</fieldGroup>
<frame id="windowActions"
screen="extendedEditWindowActions"/>
</layout>
@Named("fieldGroup.superior")
private PickerField superiorField;
@Named("fieldGroup.departmentLevel")
private PickerField departmentLevelField;
@Override
public void init(Map<String, Object> params) {
super.init(params);
superiorField.addLookupAction();
departmentLevelField.addValueChangeListener(e -> {
DepartmentLevel deptLevel = (DepartmentLevel)e.getValue();
if(deptLevel != null) {
getItem().setDepartmentLevelNo(deptLevel.getLevelNo());
superiorField.setEditable(true);
}
else {
getItem().setDepartmentLevelNo(null);
superiorField.setEditable(false);
}
});
}