前端代码
// 加载事件
OnLoad: function() {
var that = this;
this.F0000004.BindChange( "key", function() {
//前端返回后端的值
var value = that.F0000004.GetValue();
var teamValue = { teamValue: value };
//子表对象
var menu = that.D117002F3cdb9cfeac89421ebf1d17ddbf9d95f6;
$.SmartForm.PostForm( "GetTeam", teamValue, function( data ) {
//接收后端返回的数据
var result = data.ReturnData;
if( result != null ) {
//获取后台回传的子表数据
var ChildTable = result[ "tables" ];
//清除子表中的所有行
menu.ClearRows();
if( ChildTable == undefined ) {
} else {
for( var i = 0;i < ChildTable.length;i++ ) {
//填充子表
menu.AddRow( ChildTable[ i ].ValueTable.objectid, {
"D117002F3cdb9cfeac89421ebf1d17ddbf9d95f6.F0000043": ChildTable[ i ].ValueTable.F0000043,
"D117002F3cdb9cfeac89421ebf1d17ddbf9d95f6.F0000034": ChildTable[ i ].ValueTable.F0000034,
"D117002F3cdb9cfeac89421ebf1d17ddbf9d95f6.F0000040": ChildTable[ i ].ValueTable.F0000040,
})
}
}
}
},
function( data ) { $.IShowWarn( "出错啦" ); }, false );
})
},
后端代码
protected override void OnSubmit(string actionName, H3.SmartForm.SmartFormPostValue postValue, H3.SmartForm.SubmitSmartFormResponse response)
{
if(actionName == "GetTeam")
{
string teamValue = this.Request["teamValue"] + string.Empty;
//定义子表集合
List < H3.Data.Serialization.VirtualObject > ChildTable = new List<H3.Data.Serialization.VirtualObject>();
H3.IEngine engine = this.Request.Engine;
H3.Data.Filter.Filter filter = new H3.Data.Filter.Filter(); //构建过滤器
H3.Data.Filter.And andMatcher = new H3.Data.Filter.And(); //构造And匹配器
//添加查询条件 Contains:包含 Equal:等于
andMatcher.Add(new H3.Data.Filter.ItemMatcher("F0000046", H3.Data.ComparisonOperatorType.Contains, teamValue));
filter.Matcher = andMatcher;
//获取模块Schema
H3.DataModel.BizObjectSchema schema = engine.BizObjectManager.GetPublishedSchema("D117002Sxulowryv14bsvq314ad6rls95");
//查询返回的结果对象
H3.DataModel.BizObject[] boArray = H3.DataModel.BizObject.GetList(engine, H3.Organization.User.SystemUserId,
schema, H3.DataModel.GetListScopeType.GlobalAll, filter);
if(boArray != null && boArray.Length > 0)
{
for(int i = 0;i < boArray.Length; i++)
{
//处理业务对象
H3.DataModel.BizObject bo = boArray[i];
//获取子表内已有数据
H3.DataModel.BizObject[] childBoArray = (H3.DataModel.BizObject[]) bo["D117002Fyap0nm48q613i2kjmmo5niy13"];
if(childBoArray != null && childBoArray.Length > 0)
{
foreach(H3.DataModel.BizObject itemBo in childBoArray)
{
//定义子表对象
H3.Data.Serialization.VirtualObject child = new H3.Data.Serialization.VirtualObject();
//填充子表数据
child.ValueTable["F0000043"] = itemBo["F0000043"] + string.Empty;
child.ValueTable["F0000034"] = itemBo["F0000034"] + string.Empty;
child.ValueTable["F0000040"] = itemBo["F0000040"] + string.Empty;
//将子表数据添加进子表集合中
ChildTable.Add(child);
}
}
}
}
//定义返回的对象
response.ReturnData = new Dictionary<string, object>();
//返回子表集合
response.ReturnData.Add("tables", ChildTable);
}
base.OnSubmit(actionName, postValue, response);
}