Skip to content

How to change the behavior of click on node (v3.0.4) #278

Closed
@monfortm

Description

@monfortm

Hello,

I am using v3.0.4 (I have yet to move to v3.0.5 after your last push). FYI: The tree construction works flawlessly, also with async root and nodes loading. FYI again - because I've read it in another issue #260 - I also managed to tweak parent/children checkbox behavior. To control the parent checkbox: Since my nodes are loaded asynchronously, I inject the parent node model as a property on the async loaded node (parent model available as a parameter), then I am able to do target.parent.treeNodeSpec.state.input.value = false to deselect the parent when I am checking the child.

Now the issue/question:

I am wondering if it is possible to modify the behavior of the click on nodes. The default is to select the node, but I personally don't need nodes to be "selectable" - I just need my nodes to be checkable and expandable, therefore I'd like to

  • check the node when clicking the checkbox (default behavior, works well)
  • expand it when clicking the node (that is, basically, spreading the expand behavior that exist on the "+/-" expand button to the whole node except the checkbox.

Using scoped slots and the injected { model } prop, I can easily toggle the node (model.treeNodeSpec.state.expanded = !model.treeNodeSpec.state.expanded), however my nodes rely on loadChildrenAsync to load their content. I tried model[model.treeNodeSpec.childrenProperty] = model.treeNodeSpec.loadChildrenAsync(model) without success.

Maybe its already doable but I don't quite get how? Also maybe the main behavioral functions (select, check, expand) could be available as properties on slots, a bit on the fashion of checkboxChangeHandler

Let me know if this makes any sense for you,

Thanks a lot,
Cheers,
M

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions