Dynamic Columns

You can dynamically add columns to a table depending on the existing data.

The following topics are discussed:

Dynamic Column Definition

If you wanted to display a table that lists Buyers and all the Supplier Companies they work with, you could define the Buyer column, and then define the Supplier Companies columns to be added dynamically. The content of the columns would be a check mark or x or other indicator.

You can include multiple sets of dynamic columns in a table.

To dynamically add columns to a table, you need to write a custom JPO:method that retrieves the required columns and data for those columns. You use these settings on the column:


  • Column Type = Dynamic
  • Dynamic Column Program = JPO name
  • Dynamic Column Function = JPO method name

The table can include any number of specifically added columns in addition to the dynamic columns. If the table only includes dynamic columns and an empty columnMap is returned, an error is presented to the user.

This is the required method signature:

public static List getCompanyColumns(Context context, String[] 
args) throws FrameworkException

The JPO:method is provided a single args[] array containing a packed Map with these inputs:


  • requestMap--Contains the request parameters passed to emxTable.jsp or emxIndentedTable.jsp stored as a map with request parameter names as keys. Also contains objectId, relId, etc.
  • columnMap--Details of the dynamic column.
  • ObjectList--A MapList (derived from ArrayList) where each entry is a map with details about each objectid, connectionid, and so on.

The JPO:method returns a list with each entry corresponding to a column to add to the table. The columnMap matches the format returned by the UICache component for static columns defined in the administrative table. Data is stored as key/value pairs with settings stored as an additional map.

Each entry in the columnMap list is a map with this structure:

Key Description Example Value

name

The name of the column

Person List

label

The text to display as the column header.

 

href

The URL to execute when the column data is clicked

${COMMON_DIR/emxTree.jsp

${SUITE_DIR}/emxEditPartDialog.jsp

expression_businessobject

The select expression used to obtain the data for the dynamic columns and is applied to the business object specified in the Applies To administrative parameter.

type

name

$<attribute[attribute_FindNumber].value>

expression_relationship

The select expression used to obtain the data for the dynamic columns and is applied to the relationship specified in the Applies To administrative parameter.

$<attribute[attribute_FindNumber].value>

$<attribute[attribute_Qty].value>

sorttype

Defines how to sort the dynamic columns.

If you specify other, you also must specify a value for either the Sort Program or Sort Type setting for the column.

numeric

alpha (default)

other

range

Use if the column needs to have a browse button to call a chooser/custom page for the user to select a value.

${COMMON_DIR}emxTypeChooser.jsp?InclusionList=type_Part

alt

For table columns defined with Column Type = Icon setting, the alternate text to display.

<text string>

settings

Key/value pairs of settings for the dynamic columns. The key of the map is the setting name. See Parameters for Toolbar Link Command Objects for a list of the supported settings. Typical settings used for dynamic commands include:

Editable

Column Type

program

Function

Input Type

Registered Suite

Window Height

Access Expression

Access Program

Access Function

 

Guidelines for Adding Dynamic Columns to a Table

You can follow these general guidelines to include a dynamic column in a table:


  1. In Business Modelerr, create a new table object.
  2. Configure the static columns for the table.
  3. Configure the dynamic column for the table. Only one column is defined as dynamic, although the end-result could be any number of columns added to the table. At minimum, include these settings:
    • Column Type = Dynamic
    • Dynamic Column Function = method_name
    • Dynamic Column Program = JPO_name
    • Registered Suite = suite_name
  4. Complete the steps required to define a table as defined in the Business Modeler Guide.

Any settings defined for the dynamic column apply to all columns added by the JPO:method, unless specifically overridden by the returned MapList.

Sample JPO Code

This code sample retrieves dynamic columns of companies.

Public static List getCompanyColumns(Context context, String[] 
args) throws FrameworkException
{
    // unpack args array to get input map
MapList programMap = (HashMap) JPO.unpackArgs(args);
// get request information
MapList paramMap = (String) programMap.get("requestMap");
//get dynamic column information
MapList columntMap = (String) programMap.get("columnMap");
// get object list
MapList ObjectList= (String) programMap.get("ObjectList");
//Define a new MapList to return.
MapList columnMapList = new MapList();
// User defined code to populate company list
// for each company
for( int i=0; i<companyList.size(); i++){
    // create a column map to be returned.
Map colMap = new HashMap();
HashMap settingsMap = new HashMap();
// Set information of Column Settings in settingsMap
settingsMap.put("Column Type","program");
settingsMap.put("program","emxUtil");
settingsMap.put("function","getCompanyColumnValues");
settingsMap.put("Registered Suite","Framework");
// set column information
colMap.put("name", companyList.get(i).getName() );
colMap.put("label", companyList.get(i).getName() );
colMap.put("settings",settingsMap);
//user added key value pair.
colMap.put("Company Id", companyList.get(i).getObjectId()); 
columnMapList.put(colMap);
} 
// return final list
return columnMapList;
    }