| | |
| | | |
| | | /** |
| | | * 做一个9802设置与TreeGrid控件的映射 |
| | | * |
| | | * @author 邓文峰 date:2011-3-4 |
| | | * **/ |
| | | **/ |
| | | public class Control { |
| | | @SuppressWarnings("unchecked") |
| | | public static String getTypeName(int type,List list,String col, String displayformat,int formtype){ |
| | | String name=""; |
| | | switch(type){ |
| | | public static String getTypeName(int type, List list, String col, String displayformat, int formtype) { |
| | | String name = ""; |
| | | switch (type) { |
| | | |
| | | case 2://下拉列表 |
| | | case 31://31下拉列表 |
| | | case 43://下拉列表,多选 |
| | | name="Enum"; |
| | | break; |
| | | case 30://checkbox 多选 |
| | | case 32://radiobox 单选 |
| | | name="Radio"; |
| | | break; |
| | | case 5://日期 |
| | | name="Date"; |
| | | break; |
| | | case 6://checkbox ,raido |
| | | name="Bool"; |
| | | break; |
| | | case 7: |
| | | case 8://多行文本框 |
| | | name="Lines"; |
| | | break; |
| | | case 101://密码框 |
| | | name="Pass"; |
| | | break; |
| | | case 9://图片显示 |
| | | case 40://图片显示 |
| | | name="Img"; |
| | | break; |
| | | default: |
| | | name="Text"; |
| | | break; |
| | | } |
| | | ///* |
| | | //由于前端需要实现单元格值的自动计算(3*5-3),所以不能指定数值类型,因为数值类型只能录入数字 |
| | | if("Text".equalsIgnoreCase(name)){//Text类型时候需要再判断具体的类型 Int,Float,String |
| | | |
| | | for(int i=0;i<list.size();i++){ |
| | | Map map=(Map)list.get(i); |
| | | if(col.equalsIgnoreCase((String)map.get("column_name"))){ |
| | | return getTypeName((String) map.get("data_type")); |
| | | } |
| | | } |
| | | |
| | | } |
| | | // */ |
| | | return name; |
| | | |
| | | } |
| | | private static String getTypeName(String type){ |
| | | if(type.equalsIgnoreCase("tinyint")|| |
| | | type.equalsIgnoreCase("smallint")|| |
| | | type.equalsIgnoreCase("bigint")|| |
| | | type.equalsIgnoreCase("int")) |
| | | return "Int' EditMask='.?' AcceptNaN='2";//增加EditMask='.?' AcceptNaN='2 是为了执行单元格公式(=9+2)用 |
| | | else if(type.equalsIgnoreCase("real")|| |
| | | type.equalsIgnoreCase("money")|| |
| | | type.equalsIgnoreCase("float")|| |
| | | type.equalsIgnoreCase("numeric")|| |
| | | type.equalsIgnoreCase("smallmoney")|| |
| | | type.equalsIgnoreCase("decimal")) |
| | | case 2://下拉列表 |
| | | case 31://31下拉列表 |
| | | case 43://下拉列表,多选 |
| | | name = "Enum"; |
| | | break; |
| | | case 30://checkbox 多选 |
| | | case 32://radiobox 单选 |
| | | name = "Radio"; |
| | | break; |
| | | case 5://日期 |
| | | name = "Date"; |
| | | break; |
| | | case 6://checkbox ,raido |
| | | name = "Bool"; |
| | | break; |
| | | case 7: |
| | | case 8://多行文本框 |
| | | name = "Lines"; |
| | | break; |
| | | case 101://密码框 |
| | | name = "Pass"; |
| | | break; |
| | | case 9://图片显示 |
| | | case 40://图片显示 |
| | | name = "Img"; |
| | | break; |
| | | default: |
| | | name = "Text"; |
| | | break; |
| | | } |
| | | ///* |
| | | //由于前端需要实现单元格值的自动计算(3*5-3),所以不能指定数值类型,因为数值类型只能录入数字 |
| | | if ("Text".equalsIgnoreCase(name)) {//Text类型时候需要再判断具体的类型 Int,Float,String |
| | | |
| | | return "Float' EditMask='.?' AcceptNaN='2"; |
| | | else |
| | | for (int i = 0; i < list.size(); i++) { |
| | | Map map = (Map) list.get(i); |
| | | if (col.equalsIgnoreCase((String) map.get("column_name"))) { |
| | | return getTypeName((String) map.get("data_type")); |
| | | } |
| | | } |
| | | |
| | | return "Text"; |
| | | } |
| | | private String name; |
| | | private String context; |
| | | private String script; |
| | | private int type; |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | public String getContext() { |
| | | return context; |
| | | } |
| | | public void setContext(String context) { |
| | | this.context = context; |
| | | } |
| | | public String getScript() { |
| | | return script; |
| | | } |
| | | public void setScript(String script) { |
| | | this.script = script; |
| | | } |
| | | /** |
| | | * 控件是否为只需要引用外部JS,则只需要定义名称就可以 |
| | | * */ |
| | | public boolean isScript(){ |
| | | return (this.script!=null||this.script!="")?true:false; |
| | | } |
| | | public String toString(){ |
| | | StringBuilder sb=new StringBuilder(); |
| | | if(this.name!=null&&this.name.length()!=0)//有name属性表明需要加上editor编辑器 |
| | | sb.append(this.name); |
| | | else if(this.context!=null)//否则增加自定义renderer属性 |
| | | sb.append(this.context.replaceAll("\n\t", "")); |
| | | else |
| | | sb.append("editor: { type : 'text' @options}"); |
| | | return sb.toString(); |
| | | } |
| | | } |
| | | // */ |
| | | return name; |
| | | |
| | | } |
| | | |
| | | private static String getTypeName(String type) { |
| | | if (type.equalsIgnoreCase("tinyint") || |
| | | type.equalsIgnoreCase("smallint") || |
| | | type.equalsIgnoreCase("bigint") || |
| | | type.equalsIgnoreCase("int")) |
| | | return "Int' EditMask='.?' AcceptNaN='2";//增加EditMask='.?' AcceptNaN='2 是为了执行单元格公式(=9+2)用 |
| | | else if (type.equalsIgnoreCase("real") || |
| | | type.equalsIgnoreCase("money") || |
| | | type.equalsIgnoreCase("float") || |
| | | type.equalsIgnoreCase("numeric") || |
| | | type.equalsIgnoreCase("smallmoney") || |
| | | type.equalsIgnoreCase("decimal")) |
| | | |
| | | return "Float' EditMask='.?' AcceptNaN='2"; |
| | | else |
| | | |
| | | return "Text"; |
| | | } |
| | | |
| | | private String name; |
| | | private String context; |
| | | private String script; |
| | | private int type; |
| | | |
| | | public int getType() { |
| | | return type; |
| | | } |
| | | |
| | | public void setType(int type) { |
| | | this.type = type; |
| | | } |
| | | |
| | | public String getName() { |
| | | return name; |
| | | } |
| | | |
| | | public void setName(String name) { |
| | | this.name = name; |
| | | } |
| | | |
| | | public String getContext() { |
| | | return context; |
| | | } |
| | | |
| | | public void setContext(String context) { |
| | | this.context = context; |
| | | } |
| | | |
| | | public String getScript() { |
| | | return script; |
| | | } |
| | | |
| | | public void setScript(String script) { |
| | | this.script = script; |
| | | } |
| | | |
| | | /** |
| | | * 控件是否为只需要引用外部JS,则只需要定义名称就可以 |
| | | */ |
| | | public boolean isScript() { |
| | | return (this.script != null || this.script != "") ? true : false; |
| | | } |
| | | |
| | | public String toString() { |
| | | StringBuilder sb = new StringBuilder(); |
| | | if (this.name != null && this.name.length() != 0)//有name属性表明需要加上editor编辑器 |
| | | sb.append(this.name); |
| | | else if (this.context != null)//否则增加自定义renderer属性 |
| | | sb.append(this.context.replaceAll("\n\t", "")); |
| | | else |
| | | sb.append("editor: { type : 'text' @options}"); |
| | | return sb.toString(); |
| | | } |
| | | } |