We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

Refreshing Treeview using Ajax

Thread ID:

Created:

Updated:

Platform:

Replies:

95250 Jun 28,2010 10:23 PM Jul 5,2010 03:45 AM ASP.NET MVC (Classic) 8
loading
Tags: Tools
Dennis Morales
Asked On June 28, 2010 10:23 PM

Hi,
Is it possible to refresh the MVC treeview using Ajax?

Thanks

Dennis Morales
Replied On June 29, 2010 03:44 AM

Just an update.

I am doing the refresh of treeview nodes by dynamically replacing the
list items Elements(UL/LI) and then calling the $create

$create(Syncfusion.MVC.Tools.TreeView,
{ "AllowEdit": false, "CollapseAll": false, "DragDrop": false, "ExpandAll": false, "HTML": "treemodel", "ShowLine": true, "Skin": "WindowsXP" },
null, null, $get("treeview"));


My problem with this is that it seems that calling the $create method appends a new double click item event which does the double click event twice. (the behavior of double click on item expands the item then closes it back again). How can I prevent the double click event from being assigned to the nodes if it already exists. Thanks

Prem Kumar D [Syncfusion]
Replied On June 29, 2010 04:58 AM

Hi Dennis,

Thanks for using Syncfusion products

With regards to your query, we have a work around to get rid of this problem. You can call the below method 'Unwire_TreeViewEvents' before calling the $create(.......) on ajax post

function Unwire_TreeViewEvents() {
var treeViewObj = $find("treeViewId"); //'treeViewId' - id of the control
$(treeViewObj.get_Element()).unbind('click', treeViewObj._ClickEventHandler);
$(treeViewObj.get_Element()).unbind('mouseover', treeViewObj._MouseOverHandler);
$(treeViewObj.get_Element()).unbind('mouseout', treeViewObj._MouseOutHandler);
$(treeViewObj.get_Element()).unbind('dblclick', treeViewObj._inlineEdit);
if ($.browser.opera)
$(document).unbind('keypress', treeViewObj._pressF2Key);
else
$(document).unbind('keydown', treeViewObj._pressF2Key);
}

However this method will be available internally in our upcoming release.Let me know if you have any queries.

Best Regards,
Premkumar

Dennis Morales
Replied On June 29, 2010 05:27 AM

Thanks premkumar, your solution fixed the problem.

Another thing is that I am wondering if there is a method that would get all the collapsed items? That way I can collapse/expand all the previous items.

Prem Kumar D [Syncfusion]
Replied On June 29, 2010 10:35 AM

Hi Dennis,

You can get the array of collapsed tree view items from the below code:

var collapsedItems = $("#MyTreeView").find('li[class~=collapse]');

where, 'MyTreeView' is the id of the treeview control

Let me know if you have any queries

Best Regards,
Premkumar

Dennis Morales
Replied On June 29, 2010 09:55 PM

Thanks

Prem Kumar D [Syncfusion]
Replied On June 29, 2010 11:48 PM

Hi Dennis,

We are glad to hear that your problem has been resolved. Donot hesitate to get back to us for any further queries

Best Regards,
Premkumar

Dennis Morales
Replied On July 5, 2010 03:36 AM

I noticed that the click event was not firing after i called the $create method. Everything else is working fine except the click event of treeview

Dennis Morales
Replied On July 5, 2010 03:45 AM

I got it already.

I forgot to pass the ClientSideNodeClick event on the create method.

$create(Syncfusion.MVC.Tools.TreeView,
{ "AllowEdit": false, "CollapseAll": false, "DragDrop": false, "ExpandAll": false, "HTML": "treemodel", "ShowLine": true, "Skin": "WindowsXP" },
{ "ClientSideOnNodeClick": ReportList_ReportsTreeClick }, null, $get("treeview"));

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;