Collapse when click header with autoCollapse = false

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

    • Post Options:
    • Link

    Posted 25 November 2020, 8:16 pm EST

    Hi,

    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 https://jsfiddle.net/LaAsCE/c3p2josf/

    Can you help me?

    Regards~

  • Posted 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:

    https://stackblitz.com/edit/js-fc8lug

    Regards,

    Ashwin

  • Posted 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 https://jsfiddle.net/LaAsCE/c3p2josf/

    Is there any difference way?

    Regards,

    Tam

  • Posted 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.

    https://jsfiddle.net/39fwkag7/3/

    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.

    ~regards

  • Posted 3 December 2020, 1:53 pm EST

    Thank you for your response.

    It’s good to know that.

    Regards

Need extra support?

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

Learn More

Forum Channels