Dynamic Column DefinitionIf 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:
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:
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:
Guidelines for Adding Dynamic Columns to a TableYou can follow these general guidelines to include a dynamic column in a table:
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 CodeThis 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; } |