分享一个table初始化的方法(绑定query,建立表头及列)

protected void initTable()
  {
    String queryName = "com.kingdee.eas.custom.glass.shop.app.MaterialDLQuery";
    if (CompareType.INCLUDE.equals(this.compareType)) {
      queryName = "com.kingdee.eas.custom.glass.shop.app.MaterialDLWithInvQuery";
    }
    this.queryPk = new MetaDataPK(queryName);
    IMetaDataLoader loader = 
      MetaDataLoaderFactory.getRemoteMetaDataLoader();
    this.queryInfo = loader.getQuery(this.queryPk);
    
    SelectorInfo selector = this.queryInfo.getSelector();
    int size = selector.getFields().size();
    String[] bindContents = new String[size];
    
    this.tblMain.getSelectManager().setSelectMode(2);
    
    this.tblMain.getStyleAttributes().setLocked(true);
    for (int i = 0; i < size; i++)
    {
      IColumn col = this.tblMain.addColumn(i);
      QueryFieldInfo field = (QueryFieldInfo)selector.getFields().get(i);
      
      Map exProperties = field.getExtendedProperties();
      if (exProperties != null)
      {
        Object visible = exProperties.get("isVisibleForKDTable");
        if ((visible instanceof Boolean)) {
          col.getStyleAttributes().setHided(
            !((Boolean)visible).booleanValue());
        }
        if ((visible instanceof String)) {
          col.getStyleAttributes().setHided(
            !
            KDCommonPromptDialog.stringToboolean((String)visible));
        }
        Object colWidth = exProperties.get("colWidthInKDTable");
        if ((colWidth instanceof Integer)) {
          col.setWidth(((Integer)colWidth).intValue());
        }
        if ((colWidth instanceof String)) {
          col.setWidth(
            KDCommonPromptDialog.stringToint((String)colWidth));
        }
      }
      bindContents[i] = field.getName();
      col.setKey(bindContents[i]);
    }
    this.tblMain.putBindContents("query", bindContents);
    this.tblMain.setFormatXml("");
    this.tblMain.checkParsed(true);
    
    IRow row = this.tblMain.addHeadRow();
    for (int i = 0; i < size; i++)
    {
      QueryFieldInfo field = (QueryFieldInfo)selector.getFields().get(i);
      String displayName = field.getDisplayName(
        SysContext.getSysContext().getLocale());
      if ((displayName == null) || (displayName.equals(""))) {
        displayName = field.getName();
      }
      row.getCell(i).setValue(displayName);
    }
    this.tblMain.addRequestRowSetListener(new RequestRowSetListener()
    {
      public void doRequestRowSet(RequestRowSetEvent e)
      {
        if (MaterialQueryUI.this.isLoad())
        {
          MaterialQueryUI.this.kdtTable_doRequestRowSet(e);
          MaterialQueryUI.this.defaultSelectRow();
        }
      }
    });
    this.tblMain.addKDTMouseListener(new KDTMouseListener()
    {
      public void tableClicked(KDTMouseEvent e)
      {
        Object originView = e.getOriginView();
        if (originView != null)
        {
          String className = originView.getClass().getName();
          if (className.equals(KDTView.class.getName())) {
            MaterialQueryUI.this.kdtTable_doClicked(e);
          }
        }
      }
    });
    this.tblMain.getDataRequestManager().setDataRequestMode(1);
    this.tblMain.doLayout();
    KDTableUtil.addSort(this.tblMain);
  }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值