Tuesday, November 13, 2012

Building a selected/available list


1. In the AOT, create a new table named InventBuyerGroupList. Do not change any of
the properties as this table is for demonstration only.


2. Add a new field to the table with the following properties (click on Yes if asked to add
a new relation to the table):

Property                   Value
Type                         String
Name                       GroupId
ExtendedDataType   ItemBuyerGroupId


3. Add another field to the table with the following properties:

Property                  Value
Type                        String
Name                      CustAccount
ExtendedDataType  CustAccount

4. In the AOT, open the InventBuyerGroup form and change the design properties
as follows:

Property     Value
Style           Auto

5. Add a new Tab control with the following properties, to the bottom of the design:

Property     Value
Width         Column width
Height        Column height

6. Add a new TabPage control with the following properties to the newly created tab:

Property     Value
Name         BuyerGroups
Caption      Buyer groups

7. Add another TabPage control with the following properties to the newly created tab:

Property     Value
Name         Customers
Caption      Customers


8. Move the existing Grid control to the first tab page and hide the existing Body group
by setting the property:

Property     Value
Visible        No

9. The form should look similar to the following screenshot:



10. Add the following line to the form's class declaration:
SysListPanelRelationTable sysListPanel;

11. Override the form's init() method with the following code:

public void init()
{
    container columns;
    #ResAppl
    columns = [fieldNum(CustTable, AccountNum)];
    sysListPanel = SysListPanelRelationTable::newForm(element, element.controlId(
    formControlStr(InventBuyerGroup,Customers)), "Selected", "Available", #ImageCustomer,


    tableNum(InventBuyerGroupList), fieldNum(InventBuyerGroupList,CustAccount),
    fieldNum(InventBuyerGroupList,GroupId), tableNum(CustTable),
    fieldNum(CustTable,AccountNum), columns);
    super();
    sysListPanel.init();
}


12. Override the pageActivated() method on the newly created Customers tab page
with the following code:

public void pageActivated()
{
    sysListPanel.parmRelationRangeValue(InventBuyerGroup.Group);
    sysListPanel.parmRelationRangeRecId(InventBuyerGroup.RecId);
    sysListPanel.fill();
    super();
}

13. In order to test the list, open Inventory and warehouse management | Setup |
Inventory | Buyer groups, select any group, go to the Customers tab page and use
the buttons provided to move records from one side to the other. You could also do a
double-click or drag-and-drop with your mouse:






No comments: