ext java 动态grid demo
程序员文章站
2022-03-29 12:17:45
...
package com.gepower.repair.vo; import java.util.ArrayList; import java.util.List; public class DynaGridList extends BaseList{ private List data; private List<ColumnModelVo> columnModel = new ArrayList<ColumnModelVo>(); private List<FieldsNameVo> fieldsNames = new ArrayList<FieldsNameVo>(); //private public DynaGridList(){ } public List getData() { return data; } public void setData(List data) { this.data = data; } public void addColumnModel(ColumnModelVo columnModelVo){ if(!columnModel.contains(columnModelVo)){ columnModel.add(columnModelVo); } } public List<ColumnModelVo> getColumnModel() { return columnModel; } public void setColumnModel(List<ColumnModelVo> columnModel) { this.columnModel = columnModel; } public void addFieldsName(FieldsNameVo fieldNameVo){ if(!fieldsNames.contains(fieldNameVo)){ fieldsNames.add(fieldNameVo); } } public List<FieldsNameVo> getFieldsNames() { return fieldsNames; } public void setFieldsNames(List<FieldsNameVo> fieldsNames) { this.fieldsNames = fieldsNames; } } public DynaGridList findMultiplierCostList( String compSegId, UserVo tempUserVo) throws Exception { List<DynaBean> dataBeanList = multiplierCostSummaryDao.findMultiplierCostList( compSegId, tempUserVo); DynaGridList result = new DynaGridList(); //List<DynaBean> data = new ArrayList<ColumnModelVo>(); List data = new ArrayList(); String klassName = null; FieldsNameVo fieldNameVo = null; ColumnModelVo columnModelVo = null; EditorVo editor = null; List<ComboVo> fieldArryList = multiplierCostSummaryDao.findFieldArry(); String[] fieldArry; if (fieldArryList.size() > 0) { fieldArry = fieldArryList.get(0).getValue().split(","); for (int i = 0; i < fieldArry.length; i++) { Iterator itr = dataBeanList.iterator(); while (itr.hasNext()) { DynaBean dbean = (DynaBean) itr.next(); Map dynaMap = new DynaBeanMapDecorator(dbean); // data.add(dynaMap); Set keySet = dynaMap.keySet(); Iterator keyIt = keySet.iterator(); while (keyIt.hasNext()) { Object obj = keyIt.next(); if (fieldArry[i].equals(obj.toString())) { System.out.println(obj + " " + dynaMap.get(obj)); DynaProperty dynaProp = dbean.getDynaClass() .getDynaProperty(obj.toString()); klassName = dynaProp.getType().getName(); fieldNameVo = new FieldsNameVo(obj.toString()); fieldNameVo.setType("String"); // need change result.addFieldsName(fieldNameVo); columnModelVo = new ColumnModelVo(getColumnHeader(obj.toString()), obj.toString(),150); // columnModelVo.setXtype("templatecolumn"); // columnModelVo.setTpl("<span class=''>{obj.toString()}</span>"); editor = new EditorVo(); editor.setXtype("textfield"); columnModelVo.setEditor(editor); result.addColumnModel(columnModelVo); } } // dbean } } Iterator itr = dataBeanList.iterator(); while (itr.hasNext()) { DynaBean dbean = (DynaBean) itr.next(); Map dynaMap = new DynaBeanMapDecorator(dbean); data.add(dynaMap); } } result.setData(data); return result; } public List<DynaBean> findMultiplierCostList( String compSegVal, UserVo tempUserVo) { Connection conn = null; PreparedStatement st = null; ResultSet rs = null; try{ String sql = " SELECT SQL_DTL FROM RCAT_SQL_TEMP WHERE SQL_FLAG ='PART_KIT_MT'"; // String sql = this.getSql(); this.findCompPartkitToursSql(compSegVal); List<ComboVo> sqlList = this.getJdbcTemplate().query(sql, new CompPartkitToursSqlMapper()); if(sqlList.size()==0){ return null; } sql = sqlList.get(0).getDisplay(); conn = this.getJdbcTemplate().getDataSource().getConnection(); st = conn.prepareStatement(sql); rs = st.executeQuery(); RowSetDynaClass rsdc = new RowSetDynaClass(rs); return rsdc.getRows(); }catch (Exception e){ e.printStackTrace(); }finally { try { if (rs != null) { rs.close(); } if (st != null) { st.close(); } if (conn != null) { conn.close(); } } catch (Exception e) { e.printStackTrace(); } } return null; }
上一篇: Java 单例的进程阻塞的一种方法
下一篇: itext导出word