Hello all, I have created a grid view of Leavemaster table and leaveApplication table. There is filed LeaveId in leaveMaster and foreign key in LeaveApplication table. i want to do when i select leaveId in LeaveAppliation table automatcally related fields like leaveName should be filled according leaveId. please suggest me solution. Thank you in advance.
A:
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;
}
Jan B. Kjeldsen
2010-04-14 11:50:07
A:
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();
}
Jan B. Kjeldsen
2010-04-14 12:14:09