Treeview rerender after client side events if using load on demand

6 posts, 0 answers
  1. Nicola
    Nicola avatar
    3 posts
    Member since:
    Sep 2013

    Posted 02 Dec 2019 Link to this post

    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?

  2. Peter Milchev
    Admin
    Peter Milchev avatar
    654 posts

    Posted 04 Dec 2019 Link to this post

    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.
  3. Nicola
    Nicola avatar
    3 posts
    Member since:
    Sep 2013

    Posted 04 Dec 2019 in reply to Peter Milchev Link to this post

    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

  4. Peter Milchev
    Admin
    Peter Milchev avatar
    654 posts

    Posted 09 Dec 2019 Link to this post

    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.
  5. Nicola
    Nicola avatar
    3 posts
    Member since:
    Sep 2013

    Posted 11 Dec 2019 in reply to Peter Milchev Link to this post

    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

  6. Peter Milchev
    Admin
    Peter Milchev avatar
    654 posts

    Posted 13 Dec 2019 Link to this post

    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.
Back to Top