TableFacade tableFacade = TableFacadeFactory.createTableFacade("structuresTable", request);
tableFacade.setColumnProperties("chkbox", "id", "formula", "molTable.molName", "molTable.cas", "mdlNumber", "molWeight");
tableFacade.setEditable(true);
tableFacade.setMaxRows(10);
tableFacade.setMaxRowsIncrements(10, 20, 30);
tableFacade.setTotalRows(cd_ids.size());
Limit limit = tableFacade.getLimit();
int rowStart = limit.getRowSelect().getRowStart();
int rowEnd = limit.getRowSelect().getRowEnd();
List<Long> curResultIds = cd_ids.subList(rowStart, rowEnd);
List<ACD1Structure> curStructures = structureService.getACD1StructuresByIds(curResultIds);
tableFacade.setItems(curStructures);
HtmlTable table = (HtmlTable) tableFacade.getTable();
table.getTableRenderer().setWidth("1000px");
table.getRow().setUniqueProperty("id");
HtmlColumn smilesColumn = table.getRow().getColumn("id");
smilesColumn.setEditable(false);
smilesColumn.setTitle(messageSource.getMessage("chemical.structure.title", null, request.getLocale()));
HtmlColumn formulaColumn = table.getRow().getColumn("formula");
formulaColumn.setEditable(false);
formulaColumn.setTitle(messageSource.getMessage("chemical.formula.title", null, request.getLocale()));
HtmlColumn molNameColumn = table.getRow().getColumn("molTable.molName");
molNameColumn.setEditable(false);
molNameColumn.setTitle(messageSource.getMessage("chemical.name.title", null, request.getLocale()));
HtmlColumn casColumn = table.getRow().getColumn("molTable.cas");
casColumn.setEditable(false);
casColumn.setTitle(messageSource.getMessage("chemical.cas.title", null, request.getLocale()));
HtmlColumn mdlNumberColumn = table.getRow().getColumn("mdlNumber");
mdlNumberColumn.setEditable(false);
mdlNumberColumn.setTitle(messageSource.getMessage("chemical.mdl.title", null, request.getLocale()));
HtmlColumn molWeightColumn = table.getRow().getColumn("molWeight");
molWeightColumn.setEditable(false);
molWeightColumn.setTitle(messageSource.getMessage("chemical.mw.title", null, request.getLocale()));
//for smiles column
smilesColumn.setFilterable(false);
smilesColumn.setSortable(false);
smilesColumn.getCellRenderer().setCellEditor(new CellEditor() {
public Object getValue(Object item, String property, int rowcount) {
Object value = new BasicCellEditor().getValue(item, property, rowcount);
String bgcolor = (rowcount % 2 == 0) ? "e3e3e3" : "ffffff";
HtmlBuilder html = new HtmlBuilder();
html.append("<img class=\"hand\" width=\"140\" onclick=\"supplierInfo('"+value+"')\" src=\""+request.getContextPath()+"/compoundsearch/showAsImage.do?id="+value+"&bgcolor="+bgcolor+"\">");
html.aEnd();
return html.toString();
}
});
//for checkbox column
HtmlColumn chkbox = table.getRow().getColumn("chkbox");
chkbox.getCellRenderer().setWorksheetEditor(new CheckboxWorksheetEditor());
chkbox.setTitle(" ");
chkbox.setFilterable(false);
chkbox.setSortable(false);
//render
String html = tableFacade.render();
posted on 2009-03-06 21:39
周锐 阅读(755)
评论(0) 编辑 收藏 所属分类:
Ajax 、
Java