Refreshing radTreeView with Bound List

19 posts, 1 answers
  1. Brad
    Brad avatar
    110 posts
    Member since:
    Jun 2004

    Posted 10 Jul 2008 Link to this post

    Hi,

    I have a radTreeView that is databound to a List.  After adding an item to my List how can I refresh the TreeView?

    Currently only the items that were in the list when I first set the datasource are displayed.

    Thanks,
    Brad

  2. Jordan
    Admin
    Jordan avatar
    547 posts
    Member since:
    Sep 2012

    Posted 14 Jul 2008 Link to this post

    Hi Brad,

    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

  3. DevCraft Release
  4. Brad
    Brad avatar
    110 posts
    Member since:
    Jun 2004

    Posted 15 Jul 2008 Link to this post

    Hi Jordan,

    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

  5. Answer
    Nikolay
    Admin
    Nikolay avatar
    1723 posts
    Member since:
    Sep 2012

    Posted 18 Jul 2008 Link to this post

    Hi 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

  6. Stargazer
    Stargazer avatar
    73 posts
    Member since:
    Jan 2007

    Posted 20 Nov 2008 Link to this post

    I there!

    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!

  7. Nikolay
    Admin
    Nikolay avatar
    1723 posts
    Member since:
    Sep 2012

    Posted 25 Nov 2008 Link to this post

    Hello Stargazer,

    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.

  8. jessie
    jessie avatar
    3 posts
    Member since:
    Feb 2009

    Posted 16 Feb 2009 Link to this post

    Hi Sir,

    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

  9. Victor
    Admin
    Victor avatar
    1205 posts
    Member since:
    Sep 2012

    Posted 18 Feb 2009 Link to this post

    Hi jessie,

    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.

  10. alastairw
    alastairw avatar
    4 posts
    Member since:
    Mar 2007

    Posted 21 Dec 2009 Link to this post

    Hello All,

    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

  11. Victor
    Admin
    Victor avatar
    1205 posts
    Member since:
    Sep 2012

    Posted 22 Dec 2009 Link to this post

    Hello alastairw,

    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.

  12. Amruta
    Amruta avatar
    15 posts
    Member since:
    Apr 2009

    Posted 22 Mar 2010 Link to this post

    Hi,
    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.

  13. Victor
    Admin
    Victor avatar
    1205 posts
    Member since:
    Sep 2012

    Posted 24 Mar 2010 Link to this post

    Hi Amruta,

    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.

  14. Regin Barranco
    Regin Barranco avatar
    1 posts
    Member since:
    Mar 2010

    Posted 29 Mar 2010 Link to this post

    Hi, I'm having a similar problem. I have a treeview that uses an xmldatasource. The treeview does not refresh even though the data has changed. My code that binds the control goes something like this:


    <telerik:RadTreeView id="myTreeView" DataSourceID="myXmlDataSource" ..............................

    ---------

    void onGroupListRetrieved(string myXml)
    {
         myXmlDataSource.Data = myXml;
         myTreeView.DataBind();
    }

  15. Victor
    Admin
    Victor avatar
    1205 posts
    Member since:
    Sep 2012

    Posted 29 Mar 2010 Link to this post

    Hi Regin Barranco,

    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.

  16. Umair
    Umair avatar
    1 posts
    Member since:
    Jun 2010

    Posted 21 Jul 2010 Link to this post

    Hi.

    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

  17. Victor
    Admin
    Victor avatar
    1205 posts
    Member since:
    Sep 2012

    Posted 26 Jul 2010 Link to this post

    Hello 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.

    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

  18. Stefan
    Admin
    Stefan avatar
    2453 posts
    Member since:
    Sep 2012

    Posted 21 Mar 2011 Link to this post

    Hi Stargazer,

    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

  19. Reza
    Reza avatar
    1 posts
    Member since:
    Oct 2011

    Posted 22 Nov 2013 Link to this post

    Hi There,
    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?

  20. Stefan
    Admin
    Stefan avatar
    2453 posts
    Member since:
    Sep 2012

    Posted 25 Nov 2013 Link to this post

    Hi Reza,

    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:


    I hope this helps.

    Regards,
    Stefan
    Telerik
    TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WINFORMS.
    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 >>

Back to Top
DevCraft Release