Tree - How to initialise a selected item on first render AND how to invoke the DblClick event

See snippet https://snippet.webix.com/lq2u96vq

I am trying to achieve 2 things.

  1. How do I select the first item "root", before the first render. i.e. there must always be a selected item

  2. The context menu allows renaming, adding and deleting nodes. The rename option can be accomplished by double clicking with the mouse, BUT, how do I invoke this functionality from the Rename option in the context menu, i.e. in the contextClickProcess method.

Comments

  • How do I select the first item "root", before the first render. i.e. there must always be a selected item

    https://docs.webix.com/api__link__ui.tree_ready_config.html

    {
      ready: function(){
        this.select(this.getFirstId())
      }
    }
    

    how do I invoke this functionality from the Rename option in the context menu

    https://snippet.webix.com/c80bx9rm

  • integral, thanks for your help.

    top class support service

  • Hello, @ Michael_Ross

    Please, pay attention, in your snippet data from collection to tree are transmitted twice: the first time - via data and then via .sync(). It's better to leave only one option.
    Both methods provide the same result, but ready will be called only if the source is defined asdata.
    When using .sync() to choose the first entry and perform the correct select the best solution is to apply (sync callback)[https://docs.webix.com/desktop__data_binding.html#syncingcomponents]

    In addition to the Example with edit, I'd like to propose you an alternative variant (it's not necessary, but could be useful).
    If the context menu should open an editor on the item from which it was called, you can pre-select this item and/or use getContext() method to locate the target item (as an alternative of getting the selection)

    Above all select could be transferred to that entry, which allows synchronizing all entries

    Here is an example: https://snippet.webix.com/i4d26opk

  • Yes, I see many thanks, will refactor my code.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!