Autolookup in grid view according to selected cell value
I have created a grid view of Leavemaster table and leaveApplication table. There is field 开发者_StackOverflow社区LeaveId in LeaveMaster and foreign key in LeaveApplication table.
I want to, when I select leaveId in LeaveAppliation table, automatically have related fields like LeaveName be filled according to LeaveId.
If you only want to show the leaveName
use a display method defined on the LeaveApplicationTable
:
display EmplName leaveName()
{
return LeaveMasterTable::find(this.LeaveId).Name;
}
If you have more fields to show consider using outer-join
.
In the LeaveApplicationTable
form add the LeaveMasterTable
as a secondary datasource and use outer-join
as the joinMode
(Allow-Edit
: false).
Add a modified
method to the LeaveId
field on theLeaveApplicationTable
datasource:
public void modified()
{
super();
leaveMasterTable.data(LeaveMasterTable::find(leaveApplicationTable.LeaveId));
leaveMasterTable_ds.refresh()
}
Also change the validateWrite
and write
methods of the LeaveMasterTable
datasource to not change any data:
public boolean validateWrite()
{
return true;
}
public void write()
{
//super();
}
精彩评论