![]() |
#5 |
Участник
|
AX 2009 EP Lookup из enum
Как на портале сделать Lookup из enum.
В AxLookup в markup добавляем ContentTemplate. PHP код:
X++: using System; using System.Collections; using System.Web; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebControls.WebParts; using System.Web.UI.HtmlControls; using Microsoft.Dynamics.Framework.Portal.UI.WebControls; using Microsoft.Dynamics.Framework.Portal.UI.WebControls.WebParts; using Microsoft.Dynamics.Framework.Portal.UI; using Microsoft.Dynamics.Framework.Data.Ax; using Microsoft.Dynamics.Framework.Metadata.Ax; using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy; using ApplicationProxy = Microsoft.Dynamics.Portal.Application.Proxy; using Microsoft.Dynamics.Framework.BusinessConnector.Session; using Microsoft.Dynamics.Framework.BusinessConnector.Adapter; X++: protected void Page_Init(object sender, EventArgs e) { this.AxLookupType.Lookup +=new EventHandler<AxLookupEventArgs>(AxLookupType_Lookup); this.AxLookupType.OkClicked += new EventHandler<AxLookupEventArgs>(AxLookupType_OkClicked); } X++: protected void AxLookupType_Lookup(object sender, AxLookupEventArgs e) { AxLookup lookup = e.LookupControl; CheckBoxList eCheckBoxList = new CheckBoxList(); string iLabel; int myEnum = EnumMetadata.EnumNum(this.AxSession, "myAOTEnumName"); using (Proxy.DictEnum dictEnum = new Proxy.DictEnum(this.AxSession.AxaptaAdapter, myEnum)) { for (int i = 0; i < dictEnum.values(); i++) { iLabel = dictEnum.index2Label(i); if (string.IsNullOrEmpty(iLabel)) iLabel = dictEnum.index2Symbol(i); eCheckBoxList.Items.Add(iLabel); } } lookup.ContentTemplateContainer.Controls.Add(eCheckBoxList); } X++: void AxLookupType_OkClicked(object sender, AxLookupEventArgs e) { string lookupValue = string.Empty; CheckBoxList eCheckBoxList = (CheckBoxList)e.LookupControl.ContentTemplateContainer.Controls[0]; foreach (ListItem li in eCheckBoxList.Items) { if(li.Selected) lookupValue += (lookupValue == string.Empty ? li.Value : "," + li.Value); } e.LookupControl.TargetITextControl.Text = lookupValue; } |
|
Теги |
ax2009, enterprise portal, enum, lookup |
|
|