一、通过控件过滤

1.窗体设计页面设置好控件

企业微信截图_16412790481588.png

2.设置好控件名称

企业微信截图_16412790961801.png

3.设计主窗体的初始化前脚本

企业微信截图_16412791777363.png

企业微信截图_16412793065949.png

//公用的全局对象,建议函到 Page.Config 下
//下边为开发带过滤表格的推荐规范
Page.Config.General = {
BuildWhere : function(){
//设置过滤条件
var Name = textBox_Name.GetText();
var Code = textBox_Code.GetText();
var where = “1=1”;
if(Name){
where += “ AND Name like “ + Common.String.toQuoteSingle(“%”+Name+”%”);
}
if(Code){
where += “ AND Code like “ + Common.String.toQuoteSingle(“%”+Code+”%”);
}
return where;
},
Refresh : function(){
//刷新表格
dataGrid1.TableName = “Meterial_Basic”;
dataGrid1.TableWhere = this.BuildWhere();
dataGrid1.TableOrderBy = “DispOrder asc”
dataGrid1.Refresh();
}
}

4.设计主窗体的初始化后脚本

企业微信截图_16412795561918.png
Page.Config.General.Refresh();

5.设计按钮点击事件

企业微信截图_16412794233304.png
企业微信截图_1641279502940.png

二、通过工具条过滤

1.增加过滤工具条

企业微信截图_1641280826132.png
企业微信截图_16412808909499.png

2.添加工具条过滤代码的数据服务

企业微信截图_16414366985707.png
添加参数
企业微信截图_16414367162895.png
企业微信截图_16414367388870.png
编写脚本
企业微信截图_1641436758249.png
Select ‘’ as [value], ‘’ as [text]
union all
Select CodeItemID as [value], CodeItemName as [text]
from SM_CodeItems
Where CodeID=@CodeID and CodeVisible=1
order by [value]

3.添加工具条下拉查找数据的数据服务

企业微信截图_1641436866559.png
添加参数
企业微信截图_16414368777011.png
企业微信截图_16414368892890.png
编写脚本
企业微信截图_16414371741024.png
SELECT TOP 10 RowID AS [value],StudentID + ‘ - ‘ + ISNULL(Name,’’) AS [text]
FROM TEST_Student
WHERE Name Like ‘%’ + @SearchValue + ‘%’ OR StudentID like ‘%’ + @SearchValue + ‘%’

4.设置过滤工具条按钮

企业微信截图_16412809457268.png

5.设置按钮具体属性

企业微信截图_16412809946602.png
下拉框按钮需要在按钮类型-设置里单独设置
企业微信截图_16412836583520.png
企业微信截图_16414364686234.png
企业微信截图_16414364844536.png
/返回数据源参数/
function() {
var args = {
CodeID: “AX”
};
return args;
}

6.添加过滤工具条至窗体

企业微信截图_16414365984690.png

7.设计主窗体的初始化前脚本

企业微信截图_164143726122.png
企业微信截图_16414374308277.png
Page.Config.General = {
BuildWhere : function(){
var personName = toolbarFilter.GetItem(“toolbarItemPersonName”).GetValue();
var sex = toolbarFilter.GetItem(“toolbarItemSex”).GetValue();
var StudentID = toolbarFilter.GetItem(“toolbarItemStudentID”).GetValue();
var where = “1=1”;
if(personName){
where += “ AND Name like “ + Common.String.toQuoteSingle(“%”+personName+”%”);
}
if(sex){
where += “ AND sex =” + Common.String.toQuoteSingle(sex);
}
if(StudentID){
where += “ AND StudentID like “ + Common.String.toQuoteSingle(“%”+StudentID+”%”);
}
return where;
},
Refresh : function(){
dataGrid1.TableName = “Test_Student”;
dataGrid1.TableWhere = this.BuildWhere();
dataGrid1.TableOrderBy = “DispOrder asc”
dataGrid1.Refresh();
}
}

8.设计主窗体的初始化后脚本

企业微信截图_16414374717632.png
Page.Config.General.Refresh();

9.设计过滤工具条的查找按钮脚本

企业微信截图_16414375698009.png
Page.Config.General.Refresh();

设计重置按钮的脚本动作
企业微信截图_16414376364615.png
企业微信截图_16414377287639.png
toolbarFilter.GetItem(“toolbarItemPersonName”).SetValue(“”);
toolbarFilter.GetItem(“toolbarItemSex”).SetValue(“”);
toolbarFilter.GetItem(“toolbarItemStudentID”).SetValue(“”);
Page.Config.General.Refresh();