fs-danaus
2021-03-05 a6a76f98715a5539c8fd77676d0ea1af5c9c5a4c
提交 | 用户 | age
a6a76f 1 package com.yc.action.grid;
F 2
3 import java.util.List;
4 import java.util.Map;
5
6 /**
7  * 做一个9802设置与TreeGrid控件的映射
8  * @author 邓文峰  date:2011-3-4
9  * **/
10 public class Control {
11     @SuppressWarnings("unchecked")
12     public static String getTypeName(int type,List list,String col, String displayformat,int formtype){
13         String name="";
14         switch(type){
15
16         case 2://下拉列表
17         case 31://31下拉列表 
18         case 43://下拉列表,多选
19             name="Enum";
20             break;
21         case 30://checkbox 多选 
22         case 32://radiobox 单选
23             name="Radio";
24             break;
25         case 5://日期
26             name="Date";
27             break;
28         case 6://checkbox ,raido
29             name="Bool";
30             break;
31         case 7:
32         case 8://多行文本框
33             name="Lines";
34             break;
35         case 101://密码框
36             name="Pass";
37             break;
38         case 9://图片显示
39         case 40://图片显示
40             name="Img";
41             break;
42         default:
43             name="Text";
44             break;        
45         }
46         ///*
47          //由于前端需要实现单元格值的自动计算(3*5-3),所以不能指定数值类型,因为数值类型只能录入数字
48         if("Text".equalsIgnoreCase(name)){//Text类型时候需要再判断具体的类型 Int,Float,String
49             
50             for(int i=0;i<list.size();i++){
51                 Map map=(Map)list.get(i);
52                 if(col.equalsIgnoreCase((String)map.get("column_name"))){
53                     return getTypeName((String) map.get("data_type"));
54                 }
55             }
56             
57         }
58         // */
59         return name;
60         
61     }
62     private static String getTypeName(String type){
63         if(type.equalsIgnoreCase("tinyint")||
64             type.equalsIgnoreCase("smallint")||
65             type.equalsIgnoreCase("bigint")||
66             type.equalsIgnoreCase("int"))  
67                 return "Int' EditMask='.?'  AcceptNaN='2";//增加EditMask='.?'  AcceptNaN='2 是为了执行单元格公式(=9+2)用
68         else if(type.equalsIgnoreCase("real")||
69             type.equalsIgnoreCase("money")||
70             type.equalsIgnoreCase("float")||
71             type.equalsIgnoreCase("numeric")||
72             type.equalsIgnoreCase("smallmoney")||
73             type.equalsIgnoreCase("decimal")) 
74
75                 return "Float' EditMask='.?'  AcceptNaN='2";
76         else
77
78                 return "Text";            
79     }
80     private String name;
81     private String context;
82     private String script;
83     private int type;
84     public int getType() {
85         return type;
86     }
87     public void setType(int type) {
88         this.type = type;
89     }
90     public String getName() {
91         return name;
92     }
93     public void setName(String name) {
94         this.name = name;
95     }
96     public String getContext() {
97         return context;
98     }
99     public void setContext(String context) {
100         this.context = context;
101     }
102     public String getScript() {
103         return script;
104     }
105     public void setScript(String script) {
106         this.script = script;
107     }
108     /**
109      * 控件是否为只需要引用外部JS,则只需要定义名称就可以
110      * */
111     public boolean isScript(){
112         return (this.script!=null||this.script!="")?true:false; 
113     }
114     public String toString(){
115         StringBuilder sb=new StringBuilder();
116         if(this.name!=null&&this.name.length()!=0)//有name属性表明需要加上editor编辑器
117             sb.append(this.name);
118         else if(this.context!=null)//否则增加自定义renderer属性
119             sb.append(this.context.replaceAll("\n\t", ""));
120         else
121             sb.append("editor: { type : 'text' @options}");
122         return sb.toString();
123     }
124 }