Question

I am having the tree with all my task which gets all the data from the database and i am able to display the data in the treeview panel.

Now I want to add Root node dynamically. ie. user when clicks the Add New Root Node button, I am able to create new Root in the Tree view panel.

I am able to create Child of the existing root panel but not the new Parent.

My code to add child to the already existing root node is

 text: 'Add new Root Node',
                iconCls: 'icon-save',
                handler: function () {
                    var task = taskStore.getRootNode().findChild('Name', 'Parent 1');

                    if(task) {
                        task.insertChild(0, new taskStore.model({
                            Name: 'Added as first child!',
                            PercentDone: 60,
                            StartDate : new Date(2010, 0, 6),
                            EndDate : new Date(2010, 0, 8)
                        })
                        );
                    }
                }

when I click on it everything is fine, but I want to create a New Root Node. So what I had to change to my things happen.

Your's sincerely Yogendra Singh

Was it helpful?

Solution

You can't have more than one root. You can hide root node by setting rootVisible to false, to simulate such behaviour. Here is example.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top