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

Treeview rerender after client side events if using load on demand

5 Answers 25 Views
TreeView
This is a migrated thread and some comments may be shown as answers.
Nicola
Top achievements
Rank 1
Nicola asked on 02 Dec 2019, 08:34 AM

Hi,

I ran into this issue/weird behaviour. If I setup my treeview to work with load on demand and I perform a client side action e.g. dropping a node into a container, when the action finishes, the treeview will rerender and all my NavigateUrl properties starting with a "/" will have the server address put before them.

This only happens if I use load on demand... If I build a list of objects and set it as my datasource it works fine.

Is there a way to prevent this from happening?

5 Answers, 1 is accepted

Sort by
0
Peter Milchev
Telerik team
answered on 04 Dec 2019, 09:45 AM

Hello Nicola,

Can you please share the implementation of the Load on Demand approach and sample dummy links, before and after they are modified? 

You can also use the following demos as a base so that we know which Load on Demand approach you are using and replicate it locally:

Then, we would be able to further investigate it and help you more efficiently.

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Nicola
Top achievements
Rank 1
answered on 04 Dec 2019, 01:22 PM

Hi Peter,

I'm using the Server-side Callback implementation. I used the first demo as a reference while writing my code.

Here is an example of the link I use as NavigateUrl: "/brokers/18/Shared Documents/Folder/FileName.png"

And here is the modified one: "Http://servername/brokers/18/Shared Documents/Folder/FileName.png"

I don't know if this can be helpfull but, if I try to get the NavigationUrl property on the server, even immediately after a node is created, I get: "Http://servername/brokers/18/Shared Documents/Folder/FileName.png", however, if I check the "a" tag on the client, the href attribute is still "/brokers/18/Shared Documents/Folder/FileName.png"

Regards,
Nicola

0
Peter Milchev
Telerik team
answered on 09 Dec 2019, 09:27 AM

Hello Nicola,

Thank you for sharing the further details, they helped reproducing the issue. 

The observed behavior is expected because the NavigateURL that is persisted is the one from the anchor element's href property. The href property returns the full url, hence the behavior you see:

The following script can be used to override the default behavior and save the navigateURL property: 

<script>
    Telerik.Web.UI.RadTreeNode.prototype.original_getData = Telerik.Web.UI.RadTreeNode.prototype._getData;
    Telerik.Web.UI.RadTreeNode.prototype._getData = function () {
        var navURL = this.get_navigateUrl();
        var data = this.original_getData();
        data.navigateUrl = navURL;
        return data;
    } 
</script>

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
0
Nicola
Top achievements
Rank 1
answered on 11 Dec 2019, 09:17 AM

Hello Peter,

thank you for your help. I added the script you provided to my code and now it works fine.

The only thing I'm still skeptical about is why the TreeView has to rerender after I perform a client side action like dropping a node into a container (see the Price Checker functionality in this demo: https://demos.telerik.com/aspnet-ajax/treeview/examples/overview/defaultcs.aspx). This action shouldn't affect the tree structure at all...

Thanks again.
Regards,
Nicola

0
Peter Milchev
Telerik team
answered on 13 Dec 2019, 02:28 PM

Hello Nicola,

The TreeView in the demo is rendered anew because a partial postback occurs. This postback is triggered because of the Server-side handler of the OnNodeDrop server event of the TreeView.

Regards,
Peter Milchev
Progress Telerik

Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Tags
TreeView
Asked by
Nicola
Top achievements
Rank 1
Answers by
Peter Milchev
Telerik team
Nicola
Top achievements
Rank 1
Share this question
or