This is a migrated thread and some comments may be shown as answers.
Client side binding using controller class
2 Answers 49 Views
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Vara Prasad
Top achievements
Rank 1
Vara Prasad asked on 16 Mar 2012, 04:45 PM
Hi there,

I am currently using Asp.net MVC 2010.3.1318 version in my project.

I am trying to bind treeview control through a ajax request to the controller class which will return the JSON object. 

I followed the sample give at the following location : http://demos.telerik.com/aspnet-mvc/treeview/clientsidebinding 

As far I understand, the treeview control should be able to bind any well-formed JSON object. 

I have attached the sample project, you can run it for reproducing the below error.

Homecontroller class will return the string for ajax request, which in turn converted into JSON object and binded to treeview control. 

But, I am getting the following error while binding the treeview control : Unable to get value of the property 'replace': object is null or undefined

What am I doing wrong here?

Also, the below link shows an other approach to make an ajax request

http://www.telerik.com/help/aspnet-mvc/telerik-ui-components-treeview-client-api-and-events.html 

Refer to section : Client Methods /  ajaxRequest example

I tried binding the treeview like below : 

var treeview = $('#ProductsTreeView').data('tTreeView');<br>treeview.ajax.selectUrl = '/Home/Products';<br>treeview.ajaxRequest();


But, the execution breaks saying that ajax is undefined. Is the above code supported in MVC 2010.3.1318  version? 

I didn't missed any JS scripts. I am using the below code in _Layout page
@(Html.Telerik().ScriptRegistrar().DefaultGroup(group => group.Combined(true).Compress(true)))

If I hard code the JSON object and bind it to treeview and then it works fine. Please uncomment the following code in Home/index.cshtml
for testing.

//var jsonObject = [{ Value: "1", Text: "Product 1", Expanded: true, Items: [{ Value: "4", Text: "Product 4", Expanded: true, Items: [{ Value: "6", Text: "Product 6" }, { Value: "7", Text: "Product 7"}] }, { Value: "5", Text: "Product 5"}] }, { Value: "2", Text: "Product 2 (unavailable)", Enabled: false }, { Value: "3", Text: "Product 3"}];


Any help on this will be greatly appreciated. 

Regards,
Vara

2 Answers, 1 is accepted

Sort by
0
Lars
Top achievements
Rank 1
answered on 20 Mar 2012, 03:15 PM
I have the exact same problem.

When using append to add a new node i get: Uncaught TypeError: Cannot call method 'replace' of null 
 
Did you find a solution?
0
Jero
Top achievements
Rank 1
answered on 23 Nov 2012, 08:35 AM
I have the same problem, it is a shame that the support staff don't give any answer.
Tags
TreeView
Asked by
Vara Prasad
Top achievements
Rank 1
Answers by
Lars
Top achievements
Rank 1
Jero
Top achievements
Rank 1
Share this question
or