表格圖示

表格的測試類
1 package com.xiaostudy; 2 3 import javax.servlet.http.HttpServletRequest; 4 5 import org.apache.log4j.Logger; 6 7 import wt.fc.QueryResult; 8 import wt.log4j.LogR; 9 import wt.util.WTException; 10 11 import com.ptc.core.components.descriptor.DescriptorConstants.ColumnIdentifiers; 12 import com.ptc.jca.mvc.components.JcaComponentParams; 13 import com.ptc.mvc.components.AbstractComponentBuilder; 14 import com.ptc.mvc.components.ColumnConfig; 15 import com.ptc.mvc.components.ComponentBuilder; 16 import com.ptc.mvc.components.ComponentConfig; 17 import com.ptc.mvc.components.ComponentConfigFactory; 18 import com.ptc.mvc.components.ComponentParams; 19 import com.ptc.mvc.components.TableConfig; 20 import com.ptc.netmarkets.util.beans.NmCommandBean; 21 import com.ptc.netmarkets.util.beans.NmHelperBean; 22 23 @ComponentBuilder("com.xiaostudy.Test_table") 24 public class Test_table extends AbstractComponentBuilder { 25 26 private static final String CLASSNAME = Test_table.class.getName(); 27 28 private static final Logger logger = LogR.getLogger(CLASSNAME); 29 30 @Override 31 public ComponentConfig buildComponentConfig(ComponentParams params) throws WTException { 32 logger.debug(">>>>>>" + CLASSNAME + ".buildComponentConfig()..."); 33 ComponentConfigFactory factory = getComponentConfigFactory();//得到一個組件配置工廠 34 TableConfig table = factory.newTableConfig();//設置為表格,除了表格還有tree 35 table.setType(Object.class.getName());//設置表格行對象類型,行對象的類名.class.getName() 36 table.setLabel("測試列表");//表格名稱 37 38 table.setActionModel("test_list_toolbar_actions");//設置模型 39 40 table.setSelectable(true);//顯示表格前面的選擇框 41 table.setShowCount(true);//顯示對象數量,不過windchill自動顯示,這里不設置也一樣顯示 42 table.setShowCustomViewLink(true);//設置下拉框的鏈接 43 table.setConfigurable(true);//設置此表支持可配置視圖【視圖:下拉列表】 44 table.setSingleSelect(true);//設置為單選框 45 46 ColumnConfig col = factory.newColumnConfig("常量1", true);//常量為行對象的屬性,因為行對象沒有這個屬性的話怎么顯示? 47 col.setSortable(true); 48 col.setLabel("列名1"); 49 table.addComponent(col); 50 51 table.setStrikeThroughColumn(col);//設置將用於行刪除操作的列 52 53 col = factory.newColumnConfig("常量2", true);//行對象沒有的屬性,可以通過datautility類顯示,datautility要注冊,數據到底還是要跟行對象有關聯,不然顯示什么數據? 54 col.setSortable(true);//可排列的 55 col.setLabel("列名2");//列名 56 col.setDataUtilityId("datautility類名");//聲明列是通過datautility來處理數據,直接就是datautility的類名 57 table.addComponent(col);//把列添加到表格里 58 59 col = factory.newColumnConfig(ColumnIdentifiers.MODIFIED_BY, true);//修改者 60 col.setSortable(true); 61 table.addComponent(col); 62 63 col = factory.newColumnConfig(ColumnIdentifiers.CREATED, true);//創建時間,windchill自帶,是零部件的類型,所以行對象得是零部件的子類才能用,不然只能通過datautility來顯示,但是要查看是否注冊了 64 col.setSortable(true); 65 table.addComponent(col); 66 67 col = factory.newColumnConfig(ColumnIdentifiers.LAST_MODIFIED, true);//最后修改時間 68 col.setSortable(true); 69 table.addComponent(col); 70 71 logger.debug("<<<<<<" + CLASSNAME + ".buildComponentConfig()."); 72 return table; 73 } 74 75 @Override 76 public Object buildComponentData(ComponentConfig config, ComponentParams params) throws Exception { 77 logger.debug(">>>>>>" + CLASSNAME + ".buildComponentData()..."); 78 QueryResult qr = new QueryResult(); 79 if (params instanceof JcaComponentParams) { 80 JcaComponentParams jcaCompParams = (JcaComponentParams) params; 81 NmHelperBean helper = jcaCompParams.getHelperBean(); 82 83 NmCommandBean commandBean = helper.getNmCommandBean(); 84 85 HttpServletRequest request = commandBean.getRequest(); 86 87 String strForm= (String) params.getParameter("jsp中的表單數據名"); 88 if(strForm == null) { 89 strForm = ""; 90 } 91 //qr這里查詢數據 92 } 93 logger.debug("<<<<<<" + CLASSNAME + ".buildComponentData()."); 94 return qr; 95 } 96 97 }
表格的API
setConfigurable(boolean configurable) Set whether this table supports configurable views.(設置此表是否支持可配置視圖【視圖:下拉列表】。)
setDisableAction(String disableAction) Set the disableAction for this component (設置此組件的禁用操作【禁用的action】)
setFreezable(boolean freezable) Set the component to be considered for column freezing.(設置要考慮用於列凍結的組件)
setGroupBy(String groupByColumn) Set the groupBy attribute of a TableConfig.(通過表配置的屬性設置組)
setMenubarName(String menubarName) Set the name of the action model used for menubar actions (設置用於menubar操作的操作模型的名稱)
setRowBasedObjectHandle(boolean rowBasedObjectHandle) Set whether objectHandles are needed for each row.(設置每一行是否需要對象)
setSelectable(boolean selectable) Set whether the table is selectable.(設置表是否可選擇)
setShowCustomViewLink(boolean showCustomViewLink) Set to show The customize view link in the view drop down.(設置為在視圖下拉列表中顯示定制視圖鏈接)
setSingleSelect(boolean singleSelect) Set whether in Single Select mode.(設置是否在單一選擇模式)
setSingleViewOnly(boolean singleViewOnly) Set whether component is singleViewOnly.(設置組件是否為單視圖【視圖:下拉列表】)
setStrikeThroughColumn(ColumnConfig column) Set the column which will get used for row strike-through.(設置將用於行刪除操作的列)
//set方法返回的類型都是void
String getDisableAction() Get the disableAction for this component (獲取此組件的禁用操作) Supported API: true
String getGroupBy() Returns the groupBy attribute of a TableConfig. (通過表配置的屬性返回組)
String getMenubarName() Get the name of the action model used for menubar actions (獲取用於menubar操作的操作模型的名稱) Supported API: true
ColumnConfig getStrikeThroughColumn() Returns the column which will get used for row strike-through. (返回將用於行刪除操作的列)
boolean isConfigurable() Whether the component supports configurable views. (組件是否支持可配置視圖)
boolean isFreezable() Whether the component is marked for column freeze. (組件是否標記為列凍結)
boolean isRowBasedObjectHandle() Whether objectHandles are needed for each row (每一行是否需要對象) Supported API: true
boolean isSelectable() Whether the table is selectable. (這個表格是否可選)
boolean isShowCustomViewLink() Whether to show The customize view link in the view drop down. (是否在“視圖”下拉列表中顯示“定制視圖”鏈接)
boolean isSingleSelect() Whether in Single Select mode. (是否在單一選擇模式)
boolean isSingleViewOnly() Whether the component is of singleView only. (組件是否只有一個視圖)
列API
void setAscending(boolean ascending)
Set the column sort ascending or not (設置列是否升序排序)
Supported API: true
void setAutoSize(boolean autoSize) Default value is false. (是否自動調節寬度,默認是為false)
void setCompareJsFunction(String compareJsFunction) Sets the custom compare javascript function to be used during client side sort. (設置客戶端排序期間使用的自定義比較javascript函數)
void setDataStoreOnly(boolean forDataStoreOnly) Mark the column to be included in the backing datastore, but not be displayed to the user at all. (標記要包含在備份數據存儲中的列,但完全不顯示給用戶)
void setDataType(String dataType) Default value is null. (設置數據類型,默認值為null)
void setDefaultFreeze(boolean defaultFreeze) Mark the column for default freeze, defaults to true. (將列標記為default freeze,默認為true。)
void setDefaultSecondarySort(boolean secondarySort) Mark this column for secondary sort. (為二級排序標記此列)
void setDefaultSort(boolean defaultSort) Mark this column for default sort. (將此列標記為默認排序)
void setExactWidth(boolean useExact) Default value is false. (設置准確的寬度,默認值為false)
void setSortable(boolean sortable) Mark the column to be rendered sortable, defaults to true. (標記要呈現可排序的列,默認為true)
void setVariableHeight(boolean variableHeight) Mark the column to have variable height to show its content properly (將列標記為具有可變高度以正確顯示其內容) Supported API: true
void setWidth(int columnWidth) Sets the width, in pixels, for a column in a table. (設置表中列的寬度(以像素px為單位))
String getCompareJsFunction() Get the custom compare javascript function to be used during client side sort (獲取客戶端排序期間使用的自定義比較javascript函數) Supported API: true
String getDataType() Default value is null. (獲取數據類型,默認值為null)
int getWidth() Gets the width, in pixels, for a column in a table. (獲取表中列的寬度(以像素px為單位))
boolean isAscending() Whether to sort the columns ascending (是否對列進行升序排序,默認值為true) Supported API: true
boolean isDataStoreOnly() Return whether the column is to be included in the backing datastore, but not be displayed to the user at all. (返回列是否包括在備份數據存儲中,但根本不顯示給用戶)
boolean isDefaultFreeze() Whether the column is marked for default freeze (列是否被標記為默認凍結,默認值為true) Supported API: true
boolean isDefaultSecondarySort() Is the column marked for secondary sort (列是否標記為二級排序,默認值為true) Supported API: true
boolean isDefaultSort() Is the column marked for default sort. (列是否為默認排序標記的列)
boolean isSortable() Whether the column should be rendered sortable. (該列是否應呈現可排序)
boolean isVariableHeight() Whether the column is marked to have variable height (列是否標為可變高度,默認值為true) Supported API: true
