Collapse when click header with autoCollapse = false

Posted by: darkthanhtam on 25 November 2020, 8:16 pm EST

  • Posted 25 November 2020, 8:16 pm EST


    I have a problem that I setting my tree-view with autoCollapse = false,
    and I can expand item when I click item's header,
    but I can't collapse item when I click item's header.

    Here's my example
    Can you help me?

  • Replied 26 November 2020, 7:44 pm EST

    Hi darkthanhtam,

    I have asked the developers whether this is expected behavior or bug. The internal tracking id of the case is 469521. I will update you once I will hear from them.

    In the meantime, as a workaround, you can handle the click on the TreeView and manually expand/collapse a node. Please refer to the sample below for reference:

  • Replied 29 November 2020, 5:40 pm EST

    Hi Ashwin,

    I tried your sample but that the tree view don't catch even isCollapsedChanging. And when I click at check box, it expand/collapse too (sorry because don't mention about checkbox at first). Here's the sample

    Is there any difference way?

  • Marked as Answer

    Replied 30 November 2020, 10:12 pm EST

    Hi Tam,

    Instead of using the setCollapsed method, if you will use the isCollapsed property and instead of the click event, use the mousedown event, then the isCollapsedChanging event will be fired and will be raised before the itemClicked event.

    For the checkbox issue, in the mousedown event handler, you can check whether the clicked element is not a checkbox and then expand/collapse the node accordingly.

    Also, the developers have added a collapseOnClick property in the TreeView which will be available in the next release. This property will work exactly like its name, it will collapse the node when its header is clicked.

  • Replied 3 December 2020, 1:53 pm EST

    Thank you for your response.
    It's good to know that.

Need extra support?

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

Learn More

Forum Channels