We can manually select multiple lines from the grid in any browser that we open from the lookup and then do another grid transfer with the help of code.
Take the following steps as an example.
1 - The eventHandler class of the browser that is to be invoked is added to the IDataGridSelectionKeyListener interface.
public void onInitialize(JLbsXUIControlEvent event)
{
JLbsQuerySelectionGridgrid = event.getContainer().getComponentByTag(100);
grid.setDataGridSelectionListener(this);
}
The initialize method works like this.
2 - The method definition for the browser's OnGridSetLookUp event is done as an example.
- When multiple line selections are made, the selected lines are assigned to the multiselectionlist parameter.
Note: Our Eventhandler class has added IDataGridSelectionKeyListener as an interface.
For this reason, we will need to change the getKeyAssociatedData method like this.
public void onGridSetLookupData(JLbsXUIDataGridEvent event)
{
JLbsQuerySelectionGrid grid = (JLbsQuerySelectionGrid) event.getContainer().getComponentByTag(100);
JLbsXUILookupInfo lookupInfo =(JLbsXUILookupInfo) event.getLookupData();
lookupInfo.getParameters().put("MultiSelectionList", grid.getMultiSelectionList());
}
public Object getKeyAssociatedData(Object key, Object obj)
{
return obj;
}
3 - I need to add my own method to the onInvoke definitions of the Grid created with the LookUp process.
4 - The first part of the method;
The selected areas from the browser to be selected are taken in the grid.
JLbsXUILookupInfo info = new JLbsXUILookupInfo(); boolean ok = m_Container.openChild("Forms/CBFStudent.lfrm", info, true, JLbsXUITypes.XUIMODE_DBSELECT); if ((!ok) || (info.getResult() <= 0)) return; MultiSelectionList list = (MultiSelectionList) info.getParameter("MultiSelectionList"); usersGrid = (com.lbs.grids.JLbsObjectListGrid) m_Container.getComponentByTag(2000015);
5 - The second part of the method;
- The data performs the grid assignment on the form.
for (int i = 0; i <list.size(); i++) {
QueryObjectIdentifier qId =(QueryObjectIdentifier) list.get(i);
QueryBusinessObject qbo =(QueryBusinessObject) qId.getAssociatedData();
CustomBusinessObject gridLineObject = ProjectUtil.createNewCBO("CBOCourseLine");
CustomBusinessObject studentlink = ProjectUtil.createNewCBO("StudentLink");
ProjectUtil.setMemberValueUn(gridLineObject, "StudentLink",studentlink);
ProjectUtil.setMemberValueUn(gridLineObject,"StudentLink.Name", QueryUtil.getStringProp(qbo, "NAME"));
ProjectUtil.setMemberValueUn(gridLineObject,"StudentLink.SurName",QueryUtil.getStringProp(qbo,"SURNAME"));
ProjectUtil.setMemberValueUn(gridLineObject,"StudentLink.Gender", QueryUtil.getIntProp(qbo, "GENDER"));
ProjectUtil.setMemberValueUn(gridLineObject, "Price", 123);
usersGrid.getObjects().set(usersGrid.getObjects().size()-1, gridLineObject);
addNewUserLine();
}
public void onClickSelectSubscriber(ILbsXUIPane container, Object data, IClientContextcontext) {
JLbsXUILookupInfo info = new JLbsXUILookupInfo();
boolean ok = m_Container.openChild("Forms/CBFStudent.lfrm",info, true, JLbsXUITypes.XUIMODE_DBSELECT);
if ((!ok) || (info.getResult() <= 0))
return;
MultiSelectionList list =(MultiSelectionList) info.getParameter("MultiSelectionList");
usersGrid = ((com.lbs.grids.JLbsObjectListGrid) m_Container.getComponentByTag(2000015));
for (int i = 0; i <list.size(); i++) {
QueryObjectIdentifier qId =(QueryObjectIdentifier) list.get(i);
QueryBusinessObject qbo =(QueryBusinessObject) qId.getAssociatedData();
CustomBusinessObject gridLineObject = ProjectUtil.createNewCBO("CBOCourseLine");
CustomBusinessObject studentlink = ProjectUtil.createNewCBO("StudentLink");
ProjectUtil.setMemberValueUn(gridLineObject,"StudentLink",studentlink);
ProjectUtil.setMemberValueUn(gridLineObject,"StudentLink.Name", QueryUtil.getStringProp(qbo, "NAME"));
ProjectUtil.setMemberValueUn(gridLineObject,"StudentLink.SurName", QueryUtil.getStringProp(qbo, "SURNAME"));
ProjectUtil.setMemberValueUn(gridLineObject, "StudentLink.Gender", QueryUtil.getIntProp(qbo, "GENDER"));
ProjectUtil.setMemberValueUn(gridLineObject, "Price", 123);
usersGrid.getObjects().set(usersGrid.getObjects().size()-1,gridLineObject);
addNewUserLine();
}
}
6 - It is necessary to use this method to add a new line after adding the first record of the grid.
private void addNewUserLine() {
CustomBusinessObject user = ProjectUtil.createNewCBO("CBOCourseLine");
CustomBusinessObjects users = (CustomBusinessObjects)ProjectUtil.getMemberValue(cbo, "LineLink");
users.add(user);
}