This is a migrated thread and some comments may be shown as answers.

[Solved] Index was out of range. ... error on TreeView after attempting to expand a second node on demand...

3 Answers 242 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Peter From LA
Top achievements
Rank 1
Peter From LA asked on 14 Feb 2008, 05:58 PM
We are using a RAD treeView in our application that was built couple of years ago and curently we are trying to convert to Prometheus. It expands its nodes on demand (client-side). The first expansion works like a charm, but the expansion of a second node (child or peer to the first one, it does not matter) gives me this alert message:
"Index was out of range. Must be non-negative and less than..."

Also I noticed that the second call never reaches the server-side event handler - the same one that worked fine while building the expansion of the first node.

Any ideas hos to overcome this?

3 Answers, 1 is accepted

Sort by
0
Veselin Vasilev
Telerik team
answered on 15 Feb 2008, 09:53 AM
Hi Peter Kalev,

When you add TreeNodes on the client-side (via ExpandMode.ServerSideCallBack), you should take into account that the nodes are not persisted on the server-side. Therefore, the nodes added this way cannot take part in any server-side events. Also, you cannot access the nodes on the server-side and change their properties. The nodes are accessible only on the client-side and can take part only in client-side events.

If you need to persist the expanded state of the TreeNodes after a postback, you can use the approach described in the following article:

Storing the expanded state of TreeNodes added via callback

If you need to access the nodes on the server-side, then you should definitely use ExpandMode.ServerSide. Furthermore, you can wrap the treeview with an AJAX Panel (Telerik RadAjax) that will transform each postback into a callback. Thus you will keep the needed client-side behavior.



All the best,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Peter From LA
Top achievements
Rank 1
answered on 18 Feb 2008, 11:12 PM
Well... If I have a TreeView and I click to expand a node on demand, I would not expect any magic needs to be performed to open a second node on demand, especially if the second node is a peer to the first one. Also the example on your web site works fine without the techniques you are suggesting.
0
Veselin Vasilev
Telerik team
answered on 22 Feb 2008, 08:01 AM
Hello Peter Kalev,

I think the best way to proceed is to open a formal support ticket and attach a sample project to it.
So we can test it locally and find a working solution for you.

Thanks

Regards,
Veskoni
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
TreeView
Asked by
Peter From LA
Top achievements
Rank 1
Answers by
Veselin Vasilev
Telerik team
Peter From LA
Top achievements
Rank 1
Share this question
or