I am having an issue where whenever a post back is triggered on my page the Web Data Tree empties out. Even though I'm rebinding the control on post back it still empties every time.
Hi rzwirtz,
Thank you for posting in the community.
I wasn’t able to replicate the behavior you are describing. Please check the sample I created. In order to investigate this issue further, I will need to take a look at your code or a sample project, demonstrating this behavior.
Please feel free to contact me if you have any questions.
I was able to fix the issue. What happened was I created custom control in the appcode named "NodeWebDataTree" that inherited from the infragistics web data tree. This control was bound to a collection of my own Node objects(Which are entirely different than infragistics node objects). In the init of this control I was loading up a set of nodes from a database and setting it as the data source. What I figured out is that if you set the datasource and databind in the init event it only works during the first load. If I move the setting of the datasource to the DataBinding event it on subsequent post backs.
Hello rzwirtz,
I am glad that you were able to make progress. About the nodes’ text – If you are binding the tree to a data source I suggest that you set the DataBindings, for example:
<DataBindings>
<ig:DataTreeNodeBinding DataMember="Customer" ValueField="CustomerID" TextField="CustomerName" />
<ig:DataTreeNodeBinding DataMember="Order" ValueField="OrderID" TextField="OrderID" />
<ig:DataTreeNodeBinding DataMember="OrderDetail" ValueField="ProductID" TextField="ProductName" />
</DataBindings>
If not you could set the Text property of the nodes serverside or using javascript :
var tree = $find("WebDataTree1");
tree.getNodes(0).getNode(0).set_text("Node text");
If after binding to your data source the nodes are not showing the actual values, please ensure that your tree's data bindings are set. Samples of data binding can be found here - http://samples.infragistics.com/aspnet/Samples/WebDataTree/Data/DataBinding/Default.aspx?cn=data-tree&sid=008acd5c-8589-419d-a37f-c454f52ad737.
Please let me know if this helps.
After more research into other problem I think I have found what is causing it. I have a collection of web page objects which are the top level level web pages for my website. Each of them has a collection of there child web pages, and so on and so forth. The issue arises because each one of those web page objects has two other collections on it that do not contain web page objects. I do not want these to display in the tree. If I remove the collections from my object that I do not want to display everything shows fine; it seems odd to have to do that though. My question is, how do I force the tree to only show my web page objects?
I have been reading through your post and I can suggest that you check the DataMember property of each node in NodeBound event handler. If it is different from your page object’s class, you could set it’s Visible property to false.
protected void WebDataTree1_NodeBound(object sender, DataTreeNodeEventArgs e)
{
object dataItem;
dataItem = e.Node.DataItem;
if ( dataItem.GetType().ToString() != "MyPage")
e.Node.Visible = false;
//Shows the node's parent as empty
e.Node.ParentNode.IsEmptyParent = false;
}
That works, however the node being bound at all is causing a performance issue. The way my object is written it does not load the collection of objects unless it you ask for them. Because of that doing any loading at all put performance strain on my application. The collection is a collection of documents associated with the web page object. They can be quite large, so loading them from the database when I don't even need to display them is somewhat silly. Is there any way to only have the tree bind objects of a certain type?
I suggest that you try using WebDataTree’s manual load on demand to dynamically create nodes, depending on the object type you bind them to. Demonstrative sample of this feature can be found here - http://samples.infragistics.com/aspnet/Samples/WebDataTree/Performance/ManualLoadOnDemand/Default.aspx?cn=data-tree&sid=c257cd9c-1c5a-4159-aa51-ff8ea8386395.
If you have any other questions please feel free to contact me.
I'm glad I could help. If you have any further questions please do not hesitate to ask.
That worked perfect. Thanks for the help.