20 Answers, 1 is accepted
You can "refresh" RadTreeView by resetting the data binding. That is - set the DataSource property to null and then set it again to your source.
Generally speaking, RadTreeView should add new nodes for the new items in the data source automatically. And if it doesn't you may have found a bug in the data binding that must be corrected. It will be most helpful if you can send us a sample project that demonstrates the issue. It could also be in help if you explain in more detail what is the data and how you bind RadTreeView to it.
Thank you for your cooperation.
Regards,
Jordan
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
Since having the problem with data binding I have reverted back to manually adding nodes. What I can tell you is that I tried binding the data source in the constructor and then tried binding it in my add node button click event. (Neither worked correctly at the time)
Code used to bind:
radTreeViewExplorer.DisplayMember = "Name";
radTreeViewExplorer.DataSource = projectPipes;
The object type that I am binding to List: (Generics)
private List<Pipe> projectPipes = new List<Pipe>();
The Pipe class is fairly simple consisting mostly of properties. One being "Name" which is what I linked to the display member. I also tried linking the Value member to "Name" as well; that had no effect.
Regards,
Brad
Thank you getting back to us. Your code snippet helped me to better analyze your case.
If you want RadTreeView to be updated automatically when the DataSource collection is modified, you should use BindingList instead of List. For more information about BindingList, please refer to MSDN.
If you have additional questions, feel free to contact me.
Sincerely yours,
Nikolay
the Telerik team
Instantly find answers to your questions at the new Telerik Support Center
I've also a similar problem. I have a custom BindingList<T> implemented. It's a BindingList<MyObj>. I have my TreeView bound to it as such:
rtvComponentes.Nodes.Clear(); |
rtvComponentes.SelectedNode = null; |
rtvComponentes.DisplayMember = "Designacao"; |
rtvComponentes.ValueMember = "ID"; |
rtvComponentes.ParentIDMember = "ID_Parent"; |
rtvComponentes.DataSource = MyBOJ.ListObjs; // This is of type MyObjectList<Obj>, which in turn is a BindingList<T> |
I do that once, then I had new objects to the MyBOJ.ListObjs collection. The tree stays the same. Is it because of the binding being to self-related data?
Thanks!
I was not able to reproduce any issue concerning the self-referencing data. I made a sample project which demonstrates that this scenario is working correctly on my side.
If your case is different, please open a new support ticket and send me a sample project. This will allow me to to address any potential issue further and to give you more accurate response.
Sincerely yours,
Nikolay
the Telerik team
Check out Telerik Trainer, the state of the art learning tool for Telerik products.
I would like to ask if how I could refresh the rad treeview when new node is added or deleted and all other controls when I click the refresh button. Here's is my code in splash screen upon loading(radtreeview) to main form...
Thank you and God bless...
public void PopulateMessageTree()
{
radTreeMessages.BeginUpdate();
foreach (var folder in collFolders.Where(x => x.ParentId == 0))
{
var node = new RadTreeNode(folder.Name) { ImageIndex = Constants.ICON_SMS_FOLDER, Tag = "ROOT", Key = folder.NodeId };
radTreeMessages.Nodes.Add(node);
FolderItem folder1 = folder;
foreach (var smsFolder in collFolders.Where(x => x.ParentId == folder1.NodeId))
{
var child = new RadTreeNode(smsFolder.Name) { ImageIndex = Constants.ICON_SMS, Tag = smsFolder.Name, Key = smsFolder.NodeId };
node.Nodes.Add(child);
}
}
radTreeMessages.ExpandAll();
radTreeMessages.EndUpdate();
}// End of PopulateMessageTree
Thank you for writing. I am sorry but I cannot infer anything about the code unless I see it in some kind of context. Also what do you mean by "refresh the rad treeview when new node is added or deleted and all other controls when I click the refresh button" ? The tree view refreshes automatically when nodes are added or removed.
Maybe if you send a sample project I will be able to assist you. I am looking forward to your reply.
All the best,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
I have just tried the sample and have added a textbox and this code
private void Form1_Load(object sender, EventArgs e)
{
textBox1.DataBindings.Add(
new Binding("Text", list, "name"));
}
The tree view doesnt update if i change the value in the textbox, but the underlying datasource does.
Aly suggestions?
Alastair
Please clarify what is the type of your data source. It must be a type which supports change notifications -- such as DataTable or BindingList<T>. Also if you are using custom objects, the type of your custom objects must support INotifyPropertyChanged interface. I am looking forward to your reply.
Greetings,
Victor
the Telerik team
Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
I use a list of custom object to bind to the treeview. I use OnLoadDemand for a particular node. When i click on the node, i call a wcf service method (asynch call.). After completeing event i get a new list of items and i add this list to the child list of the treeview item. At this stage, i want to refresh the treeview item which will show me the newly created child nodes. Can i achieve this using INotifyPropertyChanged interface? (I dont want to refresh the whole treeview. If i make the itemSource null and then bind it again i am able to get the newly created child nodes, but it makes the tree collapse. I dont want to make the tree collapse. ).
Please can anyone suggest me a good solution for this?
Regards.
You need to bind RadTreeView to a list that supports change notifications, for example BindingList or DataTable. This will allow RadTreeView to refresh itself once the collection changes. If you need more granular tree view refreshes, your custom objects need to implement INotifyPropertyChanged.
Regards,Victor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
<telerik:RadTreeView id="myTreeView" DataSourceID="myXmlDataSource" ..............................
---------
void onGroupListRetrieved(string myXml)
{
myXmlDataSource.Data = myXml;
myTreeView.DataBind();
}
Your question refers to RadTreeView for ASP.NET Ajax. The current form is about RadTreeView for WinForms. Please post your question in the appropriate forum section in order to get proper reply for the Telerik team.
Thank you for your understanding.
Sincerely yours,
Victor
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
I am also having same kind of problem. I have a RadTreeView, which is bound to a customized list class which is inherited from
BindingList
<T>. The problem is when I call bindingList.Add(myItem), it throws this exception "Value was either too large or too small for an Int32." Although, it doesn't give any exception on adding if the list is not bound.
This is how I am binding the tree:
private void BindTree()
{
this.treeView.DataSource = null;
this.treeView.DisplayMember = "SomeProperty";
this.treeView.ValueMember = "RecId";
this.treeView.ParentIDMember = "ChildOf";
this.treeView.DataSource = this.bindingList; //BindingList<Template>
this.treeView.DataMember = "Template";
}
Kindly tell me if I am doing any mistake?
Thanks,
Umair
Thank you for writing.
For some reason an overflow or underflow exception is occurring, but I was not able to reproduce it. Please prepare a small sample application that triggers this exception, so that I can debug it and provide a solution.
Please note that you have to open a new support ticket in order to attach your project.
I am looking forward to your reply.
Victor
the Telerik team
Please note that in Q1 2011 we have introduced a major upgrade of RadTreeView control, which is now virtualized and fully customizable. Feel free to download the latest release and try it out. For more information on our latest release refer to this blog post.
All the best,Stefan
the Telerik team
It' s not good for me to refresh data source. Because my data source is very big. So I want to change my tree (e.g. change one node parent manually without refreshing and then refresh my data source in ideal time). How can I Do that?
Thank you for writing.
If you bind the tree to a DataTable, than all changes you are doing will be "stacked" in the DataTable, and then you can push them back to the database by calling the Update method of the TableAdapter. More information is available here:
- http://msdn.microsoft.com/en-us/library/system.data.datatable(v=vs.110).aspx
- http://msdn.microsoft.com/en-us/library/bz9tthwx(v=vs.110).aspx
I hope this helps.
Regards,
Stefan
Telerik
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Hi,
I have a radTreeview bound to a BindlingList. That BindingList contains custom objects that also contain BindingLists. I use async await to populate the collections in the background. This seems to be working in that my radTreeView is being updated.
However, if I have a node expanded and an item selected...if the asynchronous populating of the treeView adds a new node...my treeview immediately collapses all the nodes. I assume there is an easy way to prevent this?
Thanks
Thank you for writing.
Since all the nodes are getting collapsed, it seems the tree is updated/refreshed. If you know when this happens or what causes it, you can save the tree state (expanded nodes and scroll position) and restore it afterwards.
If you have issues achieving that, I would suggest that you open a support ticket, where you can attach your or a sample demonstrating the undesired . Once we have it, we will be able to investigate a look for a possible solution.
Regards,
Stefan
Telerik