例-默认查询(多选)
概述
- 默认查询有多个默认值时 只支持,下拉树多选/复选框
参数
FilterType="In"
Default
="值1;值2"
示例
复选例子:
<!--下拉树多选/复选框 (默认值才支持多个默认值)--> <Column Field="RoleId" CaptionText="用户角色" FieldType="VarChar" EditType="Check" FilterType="In" Width="100px" > <Map Mode="ParentTable"> <ParentTable Name="SysRole" PTText="Caption" PTValue="SysRoleId"/> </Map> </Column>
1
2
3
4
5
6
7
8如图
例,下拉树:
<!--下拉树多选/复选框 (默认值才支持多个默认值)--> <Column Field="ObjectType" CaptionText="部门" FieldType="VarChar" EditType="DropdownTree" FilterType="Equal" Width="100px" > <Map Mode="DataSource" EmptyItem="全部"> <DataSource Type="SqlServer"> <![CDATA[ select SysUnitId V,FullName T,'' PId from SysUnit ]]> </DataSource> <DataSource Type="Oracle"> <![CDATA[ select SysUnitId V,FullName T,'' PId from SysUnit ]]> </DataSource> </Map> <Args> <!--扩展属性--> <Arg Name="isMultiSelect" Value="true"/> <Arg Name="isShowTreeCheckBox" Value="true"/> </Args> </Column>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
例-分组查询例子
概述
- 分组查询的例子
示例
配置
<QueryList> <Query Entity="SysPurview" UniqueNo="1" ColCount="6" AutoWidth="true"> <Column Field="PurviewObjectType" IsVirtual="true" CaptionText="权限对象" FieldType="VarChar" Enabled="Yes" FilterType="Equal" EditType="Dropdown" Width="150px"> <Map Mode="Dictionary"> <Dictionary Name="PurviewObjectType"/> </Map> <Args> <Arg Name="isLookUpAndInput" Value="true"></Arg> </Args> <!--事件--> <Events> <Event Name="afterChange" Script="TypeChanged()"> </Event> </Events> </Column> <Column Field="PurviewObjectId" IsVirtual="true" CaptionText="权限名称" FieldType="VarChar" Enabled="Yes" FilterType="Equal" Width="150px" EditType="Dropdown"> <Map Mode="ParentTable"> <ParentTable Name="SysUser"/> </Map> <Args> <Arg Name="isLookUpAndInput" Value="true"></Arg> </Args> <!--事件--> <Events> <Event Name="onkeypress" Script="keypress()"> </Event> </Events> </Column> <Column Field="SysModelId" IsVirtual="true" CaptionText="模块" FieldType="VarChar" Enabled="Yes" FilterType="Equal" Width="200px" EditType="DropdownTree"> <Map Mode="Internal"> <Internal Name="模块"/> </Map> </Column> <Column Field="Caption" CaptionText="业务名称" FieldType="VarChar" Enabled="Yes" FilterType="Like" EditType="TextBox" Width="200px" > </Column> <Column Field="EnabledPage" CaptionText="是否分页" FieldType="VarChar" Enabled="Yes" FilterType="Equal" EditType="Dropdown" Width="150px" Default="1" IsVirtual="true" > <Map Mode="Item"> <<Item Value="1" >启用</Item> <Item Value="0">禁用</Item> </Map> </Column> <Column Field="IsVirtual" CaptionText="业务过滤" FieldType="VarChar" Enabled="Yes" FilterType="Equal" EditType="Dropdown" Width="180px" Default="0" IsVirtual="true" > <Map Mode="Item" EmptyItem="全部"> <<Item Value="0" >非虚拟</Item> <Item Value="1">虚拟</Item> </Map> </Column> <Scripts> <Script> <![CDATA[ $(function(){ var id=Request["id"]; var type='8'; var userId=Global_SysUserId; var userName=Global_SysUserName; var typeName="用户"; if(Request["id"]) { userId=Request["id"]; userName=Request["bname"]; } if(Request['type']) { typeName=Request["typename"]; type=Request['type']; var dropdown1=GetWebDropdownControl("Search_PurviewObjectId"); dropdown1.clearOptions(); var r=Ajax.Request("WebService", "<Type>"+type+"</Type><text>"+typeName+"</text><UniqueNo>1</UniqueNo>","InitDetail"); dropdown1.LoadContent(r); } $("#Search_PurviewObjectType").attr("keyValue",type); $("#Search_PurviewObjectType").val(typeName); $("#Search_PurviewObjectId").attr("keyValue",userId); $("#Search_PurviewObjectId").val(userName); var TypeobjCon=$Create("Input"); TypeobjCon.type="Hidden"; TypeobjCon.id="TypeobjCon"; TypeobjCon.value=$("Search_PurviewObjectType").attr("keyValue"); var ObjIdCon=$("Input"); ObjIdCon.porp("type",Hidden"); ObjIdCon.prop("id","ObjIdCon"); ObjIdCon.val($("#Search_PurviewObjectId").attr("keyValue")); $(document.body).append(TypeobjCon); $(document.body)..append(ObjIdCon); }); function TypeChanged() { var type=""; var text=""; if($("#Search_PurviewObjectType")[0].dropdown) { type=$("#Search_PurviewObjectType")[0].dropdown.selectedValue; text=$("#Search_PurviewObjectType")[0].dropdown.selectedText; } var id=$("#Search_PurviewObjectId"); var dropdown1=GetWebDropdownControl("Search_PurviewObjectId"); dropdown1.clearOptions(); var r=Ajax.WebRequest("Biz/WebService/InitDetail",{type:type,text:text,uniqueNo:"1"}); dropdown1.LoadContent(r); if(dropdown1.itemsCount>0) { dropdown1.setItemSelected(dropdown1.items[0]); } } function keypress() { if(event.keyCode.toString()==13) __CommonSearch(); } //查询前事件 function __OnBeforeSearch(enabledPage) { debugger if(enabledPage==null){ enabledPage=1; }else if(typeof(enabledPage)=="object"){ enabledPage=1; } __LoadDivObj(); var type=""; if($("#Search_PurviewObjectType").attr("keyValue")) type=$("#Search_PurviewObjectType").attr("keyValue"); $("#TypeobjCon").val(type); var objId=""; if($("#Search_PurviewObjectId").attr("keyValue")) objId=$("#Search_PurviewObjectId").attr("keyValue"); $("#ObjIdCon").val(objId); if(type==""||objId=="") { alert("请选择权限对象!"); //隐藏遮盖层 __HideDivObj(); return; } return true; } function __OnAfterSearch() { alert("查询后事件调用"); return true; } function RefreshDropDown() { for(var i=0;i<8;i++) { var str="Sel"+i; var obj1=$(str); obj1.style.cssText="width:100%;text-align:center;"; if(obj1.modify=="true") { var op=document.createElement("option"); op.value=""; op.text=""; op.innerText=""; obj1.selectedIndex=-1; } } } ]]> </Script> </Scripts> </Query> </QueryList> 注意:<ColumnGroup Field="LogEntity;LogDate" Caption="第一组" Selected="false" /> Field列名称之间用“;”相隔,加载时默认选中哪一组配置selected=”true”
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174效果图:
可分别根据某个分组的查询条件来进行查询
例-查询JS应用
概述
- 点击查询前,后的JS事件调用。一般查询配置。
示例
在pt5.0中的权限管理。请到SysPurview.xml中去掉相应节点的代码然后替换成下面的XML代码。
XML代码:
<QueryList> <Query Entity="SysPurview" UniqueNo="1" ColCount="6" AutoWidth="true"> <Column Field="PurviewObjectType" IsVirtual="true" CaptionText="权限对象" FieldType="VarChar" Enabled="Yes" FilterType="Equal" EditType="Dropdown" Width="150px"> <Map Mode="Dictionary"> <Dictionary Name="PurviewObjectType"/> </Map> <Args> <Arg Name="isLookUpAndInput" Value="true"></Arg> </Args> <!--事件--> <Events> <Event Name="afterChange" Script="TypeChanged()"> </Event> </Events> </Column> <Column Field="PurviewObjectId" IsVirtual="true" CaptionText="权限名称" FieldType="VarChar" Enabled="Yes" FilterType="Equal" Width="150px" EditType="Dropdown"> <Map Mode="ParentTable"> <ParentTable Name="SysUser"/> </Map> <Args> <Arg Name="isLookUpAndInput" Value="true"></Arg> </Args> <!--事件--> <Events> <Event Name="onkeypress" Script="keypress()"> </Event> </Events> </Column> <Column Field="SysModelId" IsVirtual="true" CaptionText="模块" FieldType="VarChar" Enabled="Yes" FilterType="Equal" Width="200px" EditType="DropdownTree"> <Map Mode="Internal"> <Internal Name="模块"/> </Map> </Column> <Column Field="Caption" CaptionText="业务名称" FieldType="VarChar" Enabled="Yes" FilterType="Like" EditType="TextBox" Width="200px" > </Column> <Column Field="EnabledPage" CaptionText="是否分页" FieldType="VarChar" Enabled="Yes" FilterType="Equal" EditType="Dropdown" Width="150px" Default="1" IsVirtual="true" > <Map Mode="Item"> <<Item Value="1" >启用</Item> <Item Value="0">禁用</Item> </Map> </Column> <Column Field="IsVirtual" CaptionText="业务过滤" FieldType="VarChar" Enabled="Yes" FilterType="Equal" EditType="Dropdown" Width="180px" Default="0" IsVirtual="true" > <Map Mode="Item" EmptyItem="全部"> <<Item Value="0" >非虚拟</Item> <Item Value="1">虚拟</Item> </Map> </Column> <Scripts> <Script> <![CDATA[ $(function(){ var id=Request["id"]; var type='8'; var userId=Global_SysUserId; var userName=Global_SysUserName; var typeName="用户"; if(Request["id"]) { userId=Request["id"]; userName=Request["bname"]; } if(Request['type']) { typeName=Request["typename"]; type=Request['type']; var dropdown1=GetWebDropdownControl("Search_PurviewObjectId"); dropdown1.clearOptions(); var r=Ajax.Request("WebService", "<Type>"+type+"</Type><text>"+typeName+"</text><UniqueNo>1</UniqueNo>","InitDetail"); dropdown1.LoadContent(r); } $("#Search_PurviewObjectType").attr("keyValue",type); $("#Search_PurviewObjectType").val(typeName); $("#Search_PurviewObjectId").attr("keyValue",userId); $("#Search_PurviewObjectId").val(userName); var TypeobjCon=$Create("Input"); TypeobjCon.type="Hidden"; TypeobjCon.id="TypeobjCon"; TypeobjCon.value=$("Search_PurviewObjectType").attr("keyValue"); var ObjIdCon=$("Input"); ObjIdCon.porp("type",Hidden"); ObjIdCon.prop("id","ObjIdCon"); ObjIdCon.val($("#Search_PurviewObjectId").attr("keyValue")); $(document.body).append(TypeobjCon); $(document.body)..append(ObjIdCon); }); function TypeChanged() { var type=""; var text=""; if($("#Search_PurviewObjectType")[0].dropdown) { type=$("#Search_PurviewObjectType")[0].dropdown.selectedValue; text=$("#Search_PurviewObjectType")[0].dropdown.selectedText; } var id=$("#Search_PurviewObjectId"); var dropdown1=GetWebDropdownControl("Search_PurviewObjectId"); dropdown1.clearOptions(); var r=Ajax.WebRequest("Biz/WebService/InitDetail",{type:type,text:text,uniqueNo:"1"}); dropdown1.LoadContent(r); if(dropdown1.itemsCount>0) { dropdown1.setItemSelected(dropdown1.items[0]); } } function keypress() { if(event.keyCode.toString()==13) __CommonSearch(); } //查询前事件 function __OnBeforeSearch(enabledPage) { debugger if(enabledPage==null){ enabledPage=1; }else if(typeof(enabledPage)=="object"){ enabledPage=1; } __LoadDivObj(); var type=""; if($("#Search_PurviewObjectType").attr("keyValue")) type=$("#Search_PurviewObjectType").attr("keyValue"); $("#TypeobjCon").val(type); var objId=""; if($("#Search_PurviewObjectId").attr("keyValue")) objId=$("#Search_PurviewObjectId").attr("keyValue"); $("#ObjIdCon").val(objId); if(type==""||objId=="") { alert("请选择权限对象!"); //隐藏遮盖层 __HideDivObj(); return; } return true; } function __OnAfterSearch() { alert("查询后事件调用"); return true; } function RefreshDropDown() { for(var i=0;i<8;i++) { var str="Sel"+i; var obj1=$(str); obj1.style.cssText="width:100%;text-align:center;"; if(obj1.modify=="true") { var op=document.createElement("option"); op.value=""; op.text=""; op.innerText=""; obj1.selectedIndex=-1; } } } ]]> </Script> </Scripts> </Query> </QueryList>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
相关链接
- 下拉控件 查询前__OnBeforeSearch 查询后 __OnAfterSearch
例-各种查询列
概述
- 例-各种查询列
示例
<QueryList> <!-- /****查询列*****/ --> <Query Name="Column"> <!-- /****查询列*****/ 相关属性:(Field,CaptionText,FieldType,EditType,FilterType为必须属性) FieldType:VarChar,Double,Int32,Money,DateTime,nText FilterType:Equal,NotEqual,Than,NotLess,Less,NotThan,Like,NotLike,In,NotIn,Between EditType:NoEdit,TextBox,Calendar,Radio,Check,Dropdown,DropdownTree(已实现) ,Button,Bool,List,Combo,TreeView,Textarea,HtmlEditor,Color,Html,Iframe,Child,Image,ImageList,File,FileList(预留) 注意:js取对象 var searchObj=wm.c.getSearch(); var cell=searchObj.getCell("列名"); var val=cell.getValue(); --> <!--普通列--> <Column Field="FullName" CaptionText="人员名称" FieldType="VarChar" EditType="TextBox" FilterType="Like" Width="100px" > </Column> <!--外键下拉--> <Column Field="RoleId" CaptionText="用户角色" FieldType="VarChar" EditType="Dropdown" FilterType="In" Width="100px" > <Map Mode="ParentTable"> <ParentTable Name="SysRole" PTText="Caption" PTValue="SysRoleId"/> </Map> </Column> <!--静态下拉--> <Column Field="ObjectType" CaptionText="权限对象类型" FieldType="VarChar" EditType="Dropdown" FilterType="Equal" Width="100px" > <Map Mode="Item" EmptyItem="全部"> <Item Value="1">用户</Item> <Item Value="2">角色</Item> </Map> </Column> <!--自定义下拉--> <Column Field="ObjectType" CaptionText="权限对象" FieldType="VarChar" EditType="Dropdown" FilterType="Equal" Width="100px" > <Map Mode="DataSource" EmptyItem="全部"> <DataSource Type="SqlServer"> <![CDATA[ select SysUserId V,FullName T from SysUser union all select SysRoleId V,Caption T from SysRole ]]> </DataSource> <DataSource Type="Oracle"> <![CDATA[ select SysUserId V,FullName T from SysUser union all select SysRoleId V,Caption T from SysRole ]]> </DataSource> </Map> </Column> <!--自定义下拉树1--> <Column Field="ObjectType" CaptionText="部门" FieldType="VarChar" EditType="DropdownTree" FilterType="Equal" Width="100px" > <Map Mode="DataSource" EmptyItem="全部"> <DataSource Type="SqlServer"> <![CDATA[ select SysUnitId V,FullName T,'' PId from SysUnit ]]> </DataSource> <DataSource Type="Oracle"> <![CDATA[ select SysUnitId V,FullName T,'' PId from SysUnit ]]> </DataSource> </Map> </Column> <!--自定义下拉树2--> <Column Field="ObjectType" CaptionText="部门" FieldType="VarChar" EditType="DropdownTree" FilterType="LikeIn" Width="100px" > <Map Mode="Internal" EmptyItem="全部"> <Internal Name="部门"/> </Map> </Column> <!--字典下拉--> <Column Field="ObjectType" CaptionText="是否管理员" FieldType="VarChar" EditType="Dropdown" FilterType="LikeIn" Width="100px" > <Map Mode="Dictionary" EmptyItem="全部"> <!--全局字典,非全局字典Name不写或者不写Dictionary节点--> <Dictionary Name="Sys_Bool"/> </Map> </Column> <!--日期(Between) 注意:sql取伪变量第一个用 {@Search[LoginDate]} 第二个用 {@Search[LoginDate_2]} js取值 第一个用wm.c.getSearch().getCell("列名").getValue() 或者 $("#Search_LoginDate").val() 第二个用 wm.c.getSearch().getCell("列名2").getValue() 或者 $("#Search_LoginDate2").val() --> <Column Field="LoginDate" CaptionText="登陆时间" FieldType="DateTime" EditType="Calendar" FilterType="Between" Width="100px" DataFmt="yyyy-MM-dd" > </Column> </Query> </QueryList>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
例-查询相关方法和事件
概述
- 例-查询相关方法和事件
示例
例-查询相关方法和事件
/*********查询相关方法及事件****************/ ////查询方法 //取得查询对象 var searchObj = wm.c.getSearch(); //验证 var msg = searchObj.checkValueType(); //取得列对象 var field=""; var cell=searchObj.getCell(field); var keyValue=cell.getValue(); var text=cell.getText(); //设置值 $(cell).val(text); $(cell).attr("keyValue",keyValue); //查询 wm.c.commonSearch(); //或者 __CommonSearch(); ////预定义方法(业务自定义方法,正常返回true,否则异常退出返回false) //自定义查询前事件(查询数据收集前) function __OnBeforeSearch(settings) { //settings: fields查询的列对集合searchObj查询对象searchContainer查询html对象 // baseKey列对象前级$("#"+baseKey列对象前级)可以取得列对象 // xml查询xml串 //todo //return true/false; } //自定义数据收集事件 function __OnCollectSearch(settings) { //todo //return xml; } //自定义查询后事件(刷新网格前) function __OnAfterSearch(settings) { //todo //return true/false; }
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37