TreeView is not respecting formatter function on refresh

Posted by: gibbonsk on 8 June 2023, 9:08 am EST

    • Post Options:
    • Link

    Posted 8 June 2023, 9:08 am EST

    The following example is an amalgam of two of your TreeView demos - the “Custom Content” demo and the “Refreshing” demo. As you will see, a formatItem function is used for adding a “new” icon at the end of each node. However, if you click either of the data refresh buttons, you’ll see that the icons disappear.

    https://jscodemine.grapecity.com/sample/uo3IVMxs9EWWEybDZb_QDQ/

    When TreeView nodes are refreshed, they should still run the formatItem function to property format the node.

  • Posted 8 June 2023, 9:11 pm EST

    Hi,

    This is the expected behavior for the ‘formatItem’ event of the TreeView control, it is only triggered initially when the node elements are created. To avoid the issue you are facing you’ll have to invoke the ‘loadTree’ method of the TreeView whenever the Nodes data is changed, to load the tree again with the updated data.

    I have updated your sample implementing the same - https://jscodemine.grapecity.com/share/-eYlZsjVm067bICCBX6RmA/?IsEmbed=false&Theme=Unset&PreviewDirection=0&IsEditorShow=true&IsExplorerShow=true&IsPreviewShow=true&IsConsoleShow=true&IsRunBTNShow=false&IsResetBTNShow=false&IsOpenInCodemineBTNShow=false&PanelWidth=20&PanelWidth=50&PanelWidth=30

    Regards

  • Posted 9 June 2023, 4:10 am EST

    Yes, I am aware that the loadTree method can be used to re-render the entire tree. However, I would say that’s a poor substitute, as reloading the entire tree is slow when dealing with large data sets. If I have a tree with a 1,000 nodes and I just need to update a single node, it doesn’t make sense to re-render the entire tree; the tree because sluggish and provides a poor user experience.

    As a developer using a custom item renderer, I would expect the renderer to be run regardless of which method is used to refresh the tree. The way it’s implemented now makes the formatItem and refresh functions mutually exclusive. Please consider a revision.

  • Posted 11 June 2023, 10:08 pm EST

    Hi,

    We have forwarded your request to the dev team to add this feature as an enhancement to the control, with internal tracking id - WJM-27984. We will update you on its progress as soon as we have an update from the dev team.

    Regards

  • Posted 4 March 2024, 6:04 pm EST

    Hi,

    This feature is now added in the TreeView control, you can verify the same in the following sample, with the latest Wijmo Version, i.e. 5.20232.939 - https://jscodemine.grapecity.com/share/akhzLFXGNU_NX5h4jUcKrQ/

    Regards

  • Posted 5 March 2024, 4:04 am EST

    Wonderful, thank you.

Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels