Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
130
Expand Capability Goes Away After 1 Use?
posted

Hi,

I'm using a webtree inside a WARP to show a listing of sets and subsets in combination with a listbox to show the members of the selected set in the tree.  I'm using ManualSmartCallbacks and the DemandLoad event to populate the subsets in the tree.  Unfortunately, after I've expanded and collapsed a node, I can't expand it anymore.  I've tried emptying the contents on a collapse and emptying the contents before the populate but to no avail.

To make this a little more complicated, I was having trouble with the NodeSelectionChanged event not fired on dunamically populated nodes, so I'm using the NodeExpanded event also (which is using the same function as the DemandLoad event).

If anybody has any ideas as to how I can get the expand to work more than once . . . or if there's a better way of doing this, please let me know! 

 My HTML is pretty standard (I think) and I've removed the style stuff because that's irrelevant and big:

<igmisc:WebAsyncRefreshPanel ID="WebAsyncRefreshPanel2" runat="server" LinkedRefreshControlID="UltraWebTree1">
     <ignav:ultrawebtree id="UltraWebTree1" runat="server" WebTreeTarget="ClassicTree" LoadOnDemand=ManualSmartCallbacks             CompactRendering="false" EnableViewState="true" SingleBranchExpand="True">          

    </ignav:ultrawebtree></igmisc:WebAsyncRefreshPanel>

<igmisc:WebAsyncRefreshPanel ID="WebAsyncRefreshPanel1" runat="server" TriggerControlIDs="UltraWebTree1">
                            <asp:ListBox ID="ResourceListBox" runat="server" ></asp:ListBox></igmisc:WebAsyncRefreshPanel>

 My src is a little more squirrely and I'm hoping that I'm just missing a step somewhere:

...

private void InitializeComponent()
    {  
            //This event popluates the children of a branch
            this.UltraWebTree1.DemandLoad += new Infragistics.WebUI.UltraWebNavigator.DemandLoadEventHandler(this.UltraWebTree1_DemandLoad);

            //This event gets around a bug where the NodeSelectionChanged event doesn't fire for nodes that dynamically added
            this.UltraWebTree1.NodeExpanded += new Infragistics.WebUI.UltraWebNavigator.NodeExpandedEventHandler(this.UltraWebTree1_NodeExpanded);

            //This event populates the resource listbox
            this.UltraWebTree1.NodeSelectionChanged += new Infragistics.WebUI.UltraWebNavigator.NodeSelectionChangeEventHandler(this.UltraWebTree1_NodeSelectionChanged);
        }

private void UltraWebTree1_DemandLoad(object sender, Infragistics.WebUI.UltraWebNavigator.WebTreeNodeEventArgs e)
        {
            if (e.Node.Nodes.Count == 0)
            {
                //Get the data, dataset returns 2 columns: Name & ResourceClassId & Type
                ...
                DataSet ds3 = new DataSet();
                adapter1.Fill(ds3);

        //Figure out where we are since using relative paths with the images looks for the installed path of the dlls 

                string myUrl = Request.RawUrl;
                int stopAt = myUrl.LastIndexOf("/");
                myUrl = myUrl.Substring(0, stopAt);

                foreach (DataRow ResourceClassDR in ds3.Tables[0].Rows)
                {
                    Infragistics.WebUI.UltraWebNavigator.Node newNode = new Infragistics.WebUI.UltraWebNavigator.Node(ResourceClassDR["Name"].ToString(), ResourceClassDR["ResourceClassId"].ToString(), "", "", "");
                    newNode.DataPath = ResourceClassDR["ResourceClassId"].ToString();
                    switch (ResourceClassDR["Type"].ToString())
                    {
                        case "5":
                            newNode.ImageUrl = myUrl + "/Images/Class_Selection.gif";
                            e.Node.Nodes.Add(newNode);
                            break;
                        case "6":
                            newNode.ImageUrl = myUrl + "/Images/Class_Union.gif";
                            e.Node.Nodes.Add(newNode).ShowExpand = true;
                            break;
                        case "7":
                            newNode.ImageUrl = myUrl + "/Images/Class_Intersection.gif";
                            e.Node.Nodes.Add(newNode).ShowExpand = true;
                            break;
                        case "8":
                            newNode.ImageUrl = myUrl + "/Images/Class_Difference.gif";
                            e.Node.Nodes.Add(newNode).ShowExpand = true;
                            break;
                        default:
                            newNode.ImageUrl = myUrl + "/Images/Class_Selection.gif";
                            e.Node.Nodes.Add(newNode);
                            break;
                    }
                }
            }
            e.Node.Expanded = true;
            PopulateResourceListBox((int)Convert.ToDecimal(e.Node.DataPath));
        }

      private void UltraWebTree1_NodeExpanded(object sender, Infragistics.WebUI.UltraWebNavigator.WebTreeNodeEventArgs e)

        {
            if (e.Node.Nodes.Count == 0)
            {
                //Get the data, dataset returns 2 columns: Name & ResourceClassId & Type
                ...
                DataSet ds3 = new DataSet();
                adapter1.Fill(ds3);

        //Figure out where we are since using relative paths with the images looks for the installed path of the dlls 

                string myUrl = Request.RawUrl;
                int stopAt = myUrl.LastIndexOf("/");
                myUrl = myUrl.Substring(0, stopAt);

                foreach (DataRow ResourceClassDR in ds3.Tables[0].Rows)
                {
                    Infragistics.WebUI.UltraWebNavigator.Node newNode = new Infragistics.WebUI.UltraWebNavigator.Node(ResourceClassDR["Name"].ToString(), ResourceClassDR["ResourceClassId"].ToString(), "", "", "");
                    newNode.DataPath = ResourceClassDR["ResourceClassId"].ToString();
                    switch (ResourceClassDR["Type"].ToString())
                    {
                        case "5":
                            newNode.ImageUrl = myUrl + "/Images/Class_Selection.gif";
                            e.Node.Nodes.Add(newNode);
                            break;
                        case "6":
                            newNode.ImageUrl = myUrl + "/Images/Class_Union.gif";
                            e.Node.Nodes.Add(newNode).ShowExpand = true;
                            break;
                        case "7":
                            newNode.ImageUrl = myUrl + "/Images/Class_Intersection.gif";
                            e.Node.Nodes.Add(newNode).ShowExpand = true;
                            break;
                        case "8":
                            newNode.ImageUrl = myUrl + "/Images/Class_Difference.gif";
                            e.Node.Nodes.Add(newNode).ShowExpand = true;
                            break;
                        default:
                            newNode.ImageUrl = myUrl + "/Images/Class_Selection.gif";
                            e.Node.Nodes.Add(newNode);
                            break;
                    }
                }
            }
            e.Node.Expanded = true;
            e.Node.Selected = true;
            PopulateResourceListBox((int)Convert.ToDecimal(e.Node.DataPath));
        }
 private void UltraWebTree1_NodeSelectionChanged(object sender, Infragistics.WebUI.UltraWebNavigator.WebTreeNodeEventArgs e)
        {
            PopulateResourceListBox((int)Convert.ToDecimal(e.Node.DataPath));
        }
private void PopulateResourceListBox(int ResourceClassId)
        {
            //Get the data
            //Dataset has 2 columns, Name & ID (which is what we want as our ListItem value)
            ...
            DataSet ds3 = new DataSet();
            adapter1.Fill(ds3);
             ...
            if (ResourceListBox.Items.Count > 0) ResourceListBox.Items.Clear();

            foreach (DataRow ResourceClassDR in ds3.Tables[0].Rows)
            {
                ListItem newListItem = new ListItem(ResourceClassDR[1].ToString(), ResourceClassDR[0].ToString());
                ResourceListBox.Items.Add(newListItem);
            }
        }
Many Thanks,
Fidget 
Parents
No Data
Reply
  • 45049
    posted

    My first suggestion is, unless you specifically need both, don't use both ManualSmartCallbacks and WARP together.  Not only does using both make the scenario more complicated, it may impact your performance for no noticable gain - again, unless there's a reason to use both.

    Handling the NodeExpanded event is likely "clobbering" your nodes, specifically if you're using ManualSmartCallbacks.  The code here looks similar to what you have in the DemandLoad event, though I see you've added it to get around some other problem.

    If you need to do a significant amount of server-side programming, ManualSmartCallbacks may not be an efficient approach.  Using the WARP, along with using Manual load-on-demand, may work better for you.

Children
No Data