EnterPrise Portal 弹出子页面显示关联数据
之前做过一个AX 2009 企业门户的一个项目(简称EP),其中有一个功能是,客户为了方便,想通过下拉菜单按钮弹出一个子页面显示相关的信息数据,而不是在原页面刷新,因为在原页面刷新的话,客户想在回到之前的页面的话,又要退回到原页面,这样的话,使用起来效力确实是很低。当时因为都刚刚接触EP,毫无经验,又找不到相关的资料,我们就告诉客户这个解决不了。 通过一段时间的摸索和学习,又回想起这个需求,我就试了试,其实,这是一个不是很难完成的事情。下面我讲解该如何完成,
首先,在AX的dataset中写一个过滤方法
void RGD_InitData() { SMAServiceOrderTable serviceOrderTable; Tableid strTableid; real strRecid; QueryBuildRange tableidRange; QueryBuildRange recidRange; ; info(strfmt("%1",this.args().dataset())); if(this.args().dataset() == tablenum(SMAServiceOrderTable)) { serviceOrderTable = this.args().record(); } if(ServiceOrderTable) { strTableid = ServiceOrderTable.TableId; strRecid = ServiceOrderTable.RecId; } info("test"+serviceOrderTable.ServiceOrderId); tableidRange = DocuRef_q.dataSourceTable(tablenum(DocuRef)).addRange(fieldnum(DocuRef, RefTableid)); tableidRange.value(queryValue(strTableid)); tableidRange.status(RangeStatus::Hidden); recidRange = DocuRef_q.dataSourceTable(tablenum(DocuRef)).addRange(fieldnum(DocuRef, RefRecid)); recidRange.value(sysQuery::value(num2str(strRecid,0,0,1,0))); recidRange.status(RangeStatus::Hidden); DocuRef_ds.executeQuery(); }
然后,在我们需要弹出子页面控件里的page_Load调用这个方法
protected void Page_Load(object sender, EventArgs e) { this.dsEPDocuList.GetDataSet().DataSetRun.AxaptaObjectAdapter.Call("RGD_InitData"); }
然后在父页面的用户控件后台写代码
1,控件初始化时
void Page_Init(object sender, EventArgs e) { // Setup event handler for toolbar connected via webpart connections if (this.BaseWebpart != null) { this.BaseWebpart.SetMenuItemProperties += new EventHandler<SetMenuItemPropertiesEventArgs>(BaseWebpart_SetMenuItemProperties); this.BaseWebpart.ActionMenuItemClicking += new EventHandler<ActionMenuItemClickingEventArgs>(BaseWebpart_ActionMenuItemClicking); this.dsNBL_RailReactive.CreatingDataSetRun += new EventHandler<CreatingDataSetRunEventArgs>(dsNBL_RailReactive_CreatingDataSetRun); } }
其中,this.BaseWebpart.SetMenuItemProperties += new EventHandler<SetMenuItemPropertiesEventArgs>(BaseWebpart_SetMenuItemProperties);
void BaseWebpart_SetMenuItemProperties(object sender, SetMenuItemPropertiesEventArgs e)
{
if (String.Compare(e.MenuItem.MenuItemAOTName.ToLower(), "epserviceordercreate", true) == 0 &&
e.MenuItem is AxUrlMenuItem)
{
((AxUrlMenuItem)e.MenuItem).MenuItemContext = null;
}
}
设置弹出页面后,显示效果,比如,哪些下拉菜单该隐藏,哪些菜单该被禁用等等。。。
最重要的,this.BaseWebpart.ActionMenuItemClicking += new EventHandler<ActionMenuItemClickingEventArgs>(BaseWebpart_ActionMenuItemClicking);
void BaseWebpart_ActionMenuItemClicking(object sender, ActionMenuItemClickingEventArgs e)
{
if (e.MenuItem.MenuItemAOTName == "DocuListAction")
{
AxUrlMenuItem menuItem = new AxUrlMenuItem("EPDocuListFromInfo");
menuItem.RemoveNavigation = true;
IAxaptaRecordAdapter recordAdapter = this.dsNBL_RailReactive.GetDataSourceView("smaServiceOrderTable").DataSetView.GetCurrent ().GetRecord();
AxTableContext tableContext = AxTableContext.Create(AxTableDataKey.Create(AxSession,recordAdapter,null)); menuItem.MenuItemContext = tableContext;
this.DocuPopupParent.GetOpenPopupEventReference(menuItem); this.DocuPopupParent.OpenPopup(menuItem);
}
e.RunMenuItem = false;
}
这段代码是,当你点击下拉菜单后,弹出的子页面。
最后还有一些其他的附加代码, 我就不在粘贴了。