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

[Solved] Issue With TreeView in Ajax.BeginForm

4 Answers 104 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Kevin
Top achievements
Rank 1
Kevin asked on 09 Sep 2010, 02:19 PM
I have been having a wierd issue with the TreeView control when placed inside of an Ajax.BeginForm().  I am using the Checked Treeview sample as a starting point and basically i am trying to post the checked nodes back tot he server using ajax.  I have the TreeView in a Partial View that gets replaced after the PostBack and my Controller returns a partialView which only contains the TreeVeiw.

On the first PostBack the checked nodes are returned and the Value properties of each checked node is returned correctly.  On the second postback the checked nodel collection is returned correctly but the value field of each checked item is null. I can't for the life of me understand what is going on.  I have created a test program that completely duplicates the issue. 

I cant upload the .zip file but i have attached the 4 key pieces of the example in the source code.

The second AJAX POST to the SaveResults() controller method the vm.TopicsTree_checkedNodes has 5 entires if i select 5 items but each item in the collection has the value field as null. 

(Modified)
After reviewing the source code i thought that it might not be clear that in the SaveResults() call I am looking at the ViewModel returned using the debugger to verify the results that I have stated.  Right after that i rebuild the ViewModel to send it back to the partial view.

 I can upload the .zip with the project file if required

Thanks in advance
Kevin

4 Answers, 1 is accepted

Sort by
0
Georgi Krustev
Telerik team
answered on 09 Sep 2010, 04:08 PM
Hello Kevin,

Unfortunately it is hard to determine where exactly could be the problem.
Could you upload your test project, on one of the free upload server, like RapidShare ?
Thus we will be able to review it locally and advice you further.

Greetings,
Georgi Krustev
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
0
Kevin
Top achievements
Rank 1
answered on 09 Sep 2010, 04:30 PM
I have uploaded the project which is very simple and duplicates the issue i am having


http://rapidshare.com/files/418072000/TestTree.zip

TestTree Sample

Kevin Koenig
0
Kevin
Top achievements
Rank 1
answered on 09 Sep 2010, 08:51 PM
Some additional information on my post.  I havent figured out how to fix it yet, but it is clearly related somehow to the javascript not being run on the returned partial view.  When you run the sample you will notice that you also cant collapse the tree nodes.  Which is a clear indicator that it is a java script issue.  Maybe there is some post on this already.  If someone can point me in that direction that would realy help

Kevin Koenig
0
Accepted
Georgi Krustev
Telerik team
answered on 10 Sep 2010, 09:53 AM
Hello Kevin,

After quick review of your implementation I noticed that you override vm argument in the SaveResult Action method. I have modified and now everything works:
public ActionResult SaveResults(ViewModel vm)
{
    //vm.TopicsTree_checkedNodes is populated here
    vm.Topics = GetViewModel().Topics;
 
    if (Request.IsAjaxRequest())
    {
        var pr = new PartialViewResult();
        pr.ViewName = "ViewUserControl1";
        pr.ViewData.Model = vm;
        return pr;
    }
    else
        return RedirectToAction("Index");
}

Regards,
Georgi Krustev
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
Tags
TreeView
Asked by
Kevin
Top achievements
Rank 1
Answers by
Georgi Krustev
Telerik team
Kevin
Top achievements
Rank 1
Share this question
or