Tree View Control Example in Dynamics Ax 2009 EP

4
Tree View Control example in Dynamics Ax 2009 EP Design <table> <tr> <td> <div> <asp:TreeView ID="myTreeView" runat="server" ShowLines="True" ExpandDepth="1" MaxDataBindDepth="20" PopulateNodesFromClient="true" > <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" /> <HoverNodeStyle Font-Underline="False" /> <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" /> <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" /> </asp:TreeView> </div> </td> <td></td> <td></td></tr> </table>

description

Tree View Control Example in Dynamics Ax 2009 EP

Transcript of Tree View Control Example in Dynamics Ax 2009 EP

Page 1: Tree View Control Example in Dynamics Ax 2009 EP

Tree View Control example in Dynamics Ax 2009 EP

Design

<table> <tr> <td> <div> <asp:TreeView ID="myTreeView" runat="server" ShowLines="True" ExpandDepth="1" MaxDataBindDepth="20" PopulateNodesFromClient="true" > <ParentNodeStyle Font-Bold="True" ForeColor="#5555DD" /> <HoverNodeStyle Font-Underline="False" /> <SelectedNodeStyle Font-Underline="True" HorizontalPadding="0px" VerticalPadding="0px" /> <NodeStyle Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" HorizontalPadding="5px" NodeSpacing="0px" VerticalPadding="0px" /> </asp:TreeView> </div> </td> <td></td> <td></td></tr> </table> <dynamics:AxDataSource ID="AxDataSource1" runat="server" DataSetName="CplTmClientsDS" ProviderView="CustTable" ></dynamics:AxDataSource>

Page 2: Tree View Control Example in Dynamics Ax 2009 EP

Code behind:

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.Data.Ax;using Microsoft.Dynamics.Framework.BusinessConnector.Proxy;using Microsoft.Dynamics.Framework.BusinessConnector.Adapter;using Microsoft.Dynamics.Framework.Metadata.Ax;using ApplicationProxy = Microsoft.Dynamics.Portal.Application.Proxy;using Proxy = Microsoft.Dynamics.Framework.BusinessConnector.Proxy;using Microsoft.Dynamics.Framework.BusinessConnector.Session;

public partial class EPCustomerTreeView : System.Web.UI.UserControl{ private ISession AxSession { get { AxBaseWebPart webpart = AxBaseWebPart.GetWebpart(this); return webpart == null ? null : webpart.Session; } }

protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { displayTreeView(); } }

void displayTreeView() { IAxaptaRecordAdapter adapter = Microsoft.Dynamics.Portal.Application.Proxy.CustTable.getAllRecords(this.AxSession.AxaptaAdapter); try { int i = 0; System.Web.UI.WebControls.TreeNode myTreeNode = new System.Web.UI.WebControls.TreeNode("Customers"); myTreeView.Nodes.Add(myTreeNode); while (adapter.Found) {

Page 3: Tree View Control Example in Dynamics Ax 2009 EP

string myAccountNum = adapter.GetField("AccountNum").ToString(); string myName = adapter.GetField("Name").ToString();

System.Web.UI.WebControls.TreeNode myTreeNodec = new System.Web.UI.WebControls.TreeNode("Customer");

System.Web.UI.WebControls.TreeNode myTreeNode1 = new System.Web.UI.WebControls.TreeNode(myAccountNum); System.Web.UI.WebControls.TreeNode myTreeNode2 = new System.Web.UI.WebControls.TreeNode(myName);

myTreeView.Nodes[0].ChildNodes.Add(myTreeNodec); myTreeView.Nodes[0].ChildNodes[i].ChildNodes.Add(myTreeNode1); myTreeView.Nodes[0].ChildNodes[i].ChildNodes.Add(myTreeNode2); i++; adapter.Next(); } } finally { if (adapter != null) { adapter.Dispose(); } } } }