Home - Forums-.NET - FlyTreeView (ASP.NET) - Add button columns to tree view

FlyTreeView (ASP.NET)

Technical support and KB related to the FlyTreeView control

This forum related to following products: FlyTreeView for ASP.NET

Add button columns to tree view
Link Posted: 14-Feb-2013 05:08
A customer of us is using FlyTreeView in the enterprise portal of Dynamics AX. The tree is filled with a list of Ppojects from Dynamics AX. In addition theres a favorite box where the favorite projects of a user are stored.

Until today a project is added to the favorites when we click the checkbox.

Now our customer wants to have two button columns in the tree view. One button for the add to / delete from favorites and another one for the selection of the node and close of the tree list (which can be replaced, if its possible to use a onClick event when the node is clicked).

Is there any chance to add these columns with the desired imagebuttons?
Link Posted: 15-Feb-2013 00:51
ok, got something but its not working properly. My FlyTreeTab now looks like this in the ascx-file: [code]
" width="200px"/>
[/code] It's populated by this code in the ascx.cs-file (only level 3 shown here): [code] private void fillNodeLevel3(FlyTreeNode rootNode) { FlyTreeNode treeNode; String _object = rootNode.Value.Substring(1); int _status = 3; String tmpProjId; String tmpProjName; String tmpEmplId; epProjTree.Init(); // Set the query ranges //epProjTree.DataSetRun.AxaptaObjectAdapter.Call("setRangeToInter", new object[] { _object, _status }); epProjTree.DataSetRun.AxaptaObjectAdapter.Call("setRangeObject", new object[] { _object, _status }); // Execute the dataset to get the records epProjTree.DataSetViews[0].ExecuteQuery(); epProjTree.Run(); // Get the dataset view using (DataSetView dsProjTree = epProjTree.DataSetViews[0]) { // Loop through all records and create the tree nodes foreach (DataSetViewRow row in dsProjTree) { tmpProjId = row.GetFieldValue("ProjId").ToString(); tmpProjName = row.GetFieldValue("Name").ToString(); tmpEmplId = row.GetFieldValue("ACT_EPProjFavorites!EmplId").ToString(); treeNode = new FlyTreeNode(tmpProjId + " - " + tmpProjName); treeNode.Value = tmpProjId; treeNode.CanBeSelected = true; treeNode.PopulateNodesOnDemand = false; treeNode.Text = tmpProjId + " - " + tmpProjName; //treeNode.IsCheckbox = true; if (string.IsNullOrEmpty(tmpEmplId)) { treeNode.Checked = false; } else { treeNode.Checked = true; treeNode.BarImageUrl = "_layouts/images/Favoriten.png"; } rootNode.ChildNodes.Add(treeNode); } } } [/code] When i open the tree, the Nodes on 3rd level first look like this: when i switch to another tab and go back, the nodes on 3rd level nearly look like i want them (exept the text is missing) So my question at this point: how do I set the Layout to look like the second picture on first opening and why is the text not showing? Thanks in advance Jean
Link Posted: 18-Feb-2013 00:09
ok, I got one step closer to the target but still not working properly.

The Buttons are displayed but the onClick event (addFav / delFav) of the LinkButtons is not fired although I already replaced the ImageButtons from the prior solution (ImageButtons gave an error) and set the CssClass to noeffect.

Someone of you got any idea, whats still wrong?

In the .ascx file, I added the following code:

NineRays:FlyTreeView runat="server" ID="flyTreeView" BackColor="White" ImageSet="Office2003"
BorderColor="Silver" BorderWidth="1px" Padding="2px"  
CanBeSelected="true" SlideEffect="False" WideCell="True" ContentClickCollapses="True" PostBackOnExpand="true"
DisableSelect="false" ForceAjaxRenderer="true" DisplayBar="true" BarBackgroundImage="$bar_grey"
PostBackOnCheck="true" PostBackOnUncheck="true" PostBackOnClick="false" OnNodeCheckedChanged="flyTreeView_NodeCheckedChanged"
OnSelectedNodeChanged="flyTreeView_SelectedNodeChanged" FadeEffect="False" OnPopulateNodes="flyTreeView_PopulateNodes"
     DefaultStyle Font-Names="Tahoma" Font-Size="11px" ForeColor="Black" RowHeight="24px" Padding="0px;5px;0px;0px" /
     SelectedStyle RowBackColor="#DDDDDD" /
     HoverStyle Font-Underline="True" /
          NineRays:FlyNodeType AutoApplyAtLeaves="true" AutoApplyAtLevels="3"
                    table cellpadding="0" cellspacing="1"
                         td  asp:label runat="server" style="padding: 0px; margin: 0px" Text="" width="380px"/ /td
                         td  asp:LinkButton ID="Select" runat="server" CssClass="noeffect">Select                         td  asp:LinkButton ID="addFav" runat="server" OnClick="addFav" CssClass="noeffect"  img src="_layouts/images/Favoriten_add_w.png" alt="Add to favorites" /  /asp:LinkButton  /td
                         td  asp:LinkButton ID="delFav" runat="server" OnClick="delFav" CssClass="noeffect"  img src="_layouts/images/Favoriten_del_w.png" alt="Delete from favorites" /  /asp:LinkButton  /td
(Removed the Brackets)

In the ascx.cs file, i've got the code that should be executed:

    public void addFav(object sender, EventArgs e)
        using (Proxy.Info objInfoLog = new Proxy.Info(this.AxSession.AxaptaAdapter))
            objInfoLog.add(Proxy.Exception.Warning, "SelectedNode: " + selectedNode.Value);

            if (selectedNode.CanBeSelected == true)
                selectedNode.Checked = true;
                selectedNode.BarImageUrl = "_layouts/images/Favoriten.png";
                this.AxSession.AxaptaAdapter.CallStaticRecordMethod(strACT_EPProjFavorites, strAddFavorite, selectedNode.Value);
        catch (Exception)
Link Posted: 18-Feb-2013 05:15
Ok, i've got a huge step closer to get this to work.

First, i had to declare the LinkButton in class declaration:

LinkButton addFavButton = new LinkButton();

Then in the Page_Load, I set the event handler:

addFavButton.Click += new EventHandler(addFav);

Now there's only one single Problem left:

Whenever I click that button, the method flyTreeView_selectedNodeChanged() is executed instead. This method is set in the ascx file:

NineRays:FlyTreeView runat="server"[...] OnSelectedNodeChanged=flyTreeView_SelectedNodeChanged [...]

The flyTreeView seems not to work without that parameter. Everytime i delete it, i get an error. Any suggestions, how i can execute the methods i have written for addFav and delFav?