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);
}
分享一个table初始化的方法(绑定query,建立表头及列)
最新推荐文章于 2023-02-22 16:31:23 发布