以编程方式获取 ViewPanel 标题 [英] Getting ViewPanel Headers programmatically

查看:39
本文介绍了以编程方式获取 ViewPanel 标题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这段代码确实为我提供了我想要的组合框中的值,但我想知道是否有办法以编程方式获取 viewColumn ID、viewColumnHeader ID 和 viewPanel 中的列数.viewPanel 使用 JDBCQuery 作为数据源.

This code does provide me the values I am wanting in my comboBox, but I am wondering if there is a way to get the viewColumn ID, viewColumnHeader ID, and number of columns in the viewPanel programmatically. The viewPanel is using a JDBCQuery as the datasource.

var itemList:java.util.Vector = new java.util.Vector;
var colID = "viewColumn"; //default id assigned
var colHeaderID = "viewColumnHeader"; //default id assigned
var end = 10; //max # of viewPanel columns
itemList.add("Select Column");
for(x=1;x<end;x++) {
    try {
        if(getComponent(colID + x) == null) {
            throw ("Only " + (x-1) + " columns in ViewPanel");
        x=end;
        } else {
        var disColID = getComponent(colID + x).getColumnName();
        }
        var disColHeaderID = getComponent(colHeaderID + x).getValue();
        itemList.add(disColHeaderID + "|" + disColID);
    } catch (e) {
        dBar.info(e.toString());
    }
}

itemList

目前的方式显然仅限于 9 列,并确保 viewColumn ID 和 viewColumnHeader ID 具有特定的命名结构,这样可以避免.

The current way is obviously restricted to only 9 columns and ensuring the viewColumn ID and viewColumnHeader ID have a specific naming structure which would be nice to get away from.

推荐答案

可以通过使用 viewPanelObj.getChildren() 获取视图面板的子组件来访问视图面板的所有列.列标题是视图列的一部分,在获得视图列的句柄后,您可以使用 viewColumnObj.getHeader() 访问标题.

All the columns of a view panel can be accessed by getting the child components of view panel using viewPanelObj.getChildren(). The column headers are a part of view column and after you get the handle of view column you can access the header using viewColumnObj.getHeader().

因此,用于访问所有视图列和视图标题的示例 SSJS 代码如下所示:

So a sample SSJS code to access all the view columns and view headers would look something like this:

var viewPnl:com.ibm.xsp.component.xp.XspViewPanel = getComponent("viewPanel1");
var list:java.util.List = viewPnl.getChildren();
for (var i=0 ; i<list.size() ; i++) {
    var viewCol:com.ibm.xsp.component.xp.XspViewColumn = list.get(i);
    var viewHdr:com.ibm.xsp.component.xp.XspViewColumnHeader = viewCol.getHeader();

    // Perform required operations on objects of viewCol & viewHdr
}

这篇关于以编程方式获取 ViewPanel 标题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆