Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Request] QTree enhancement #2711

Closed
hawkeye64 opened this issue Oct 29, 2018 · 1 comment
Closed

[Request] QTree enhancement #2711

hawkeye64 opened this issue Oct 29, 2018 · 1 comment

Comments

@hawkeye64
Copy link
Member

hawkeye64 commented Oct 29, 2018

@rstoenescu
First of all, thank you for such great quality in a product. World class!
I started using QTree in an Electron product and it's very similar to a file explorer structure. Directories on the left and child contents of the selected directory on the right. Above the QTree is a number of shortcuts (Home, Documents, Downloads, etc -- directories).
What I wanted is that if a user selects one of these shortcuts, or a folder on the right, that the QTree is able to open and select the proper node.
I am doing this using an "undocumented" function,setExpanded, in the QTree. This occurs after I collect the children information of that folder.

    selectFolder: function (absolutePath) {
      // get parts for the path
      let parts = absolutePath.split('/')
      let path = ''
      let lastNodeKey

      // iterate through the path parts.
      // This code will get the node. If the node is not found,
      // it forces lazy-get by programmatically expanding
      // the parent node.
      for (let index = 1; index < parts.length; ++index) {
        path += '/' + parts[index]
        if (index > 0) {
          if ('folders' in this.$refs) {
            const key = this.$refs.folders.getNodeByKey(path)
            if (key) {
              lastNodeKey = key
            }
            else {
              if (lastNodeKey && lastNodeKey.children.length === 0) {
                this.$refs.folders.setExpanded(lastNodeKey.nodeKey, true)
              }
            }
          }
        }
      }
      this.selected = path
    },

This works pretty good, but I am concerned about it being undocumented. Is there a possibility this can be added in the documentation for QTree Methods?

Now, the enhancement part...
If a user has a large amount of folders (or expanded folders), when a folder is programmatically expanded and the the expanded key is not visible, that there would be an option to call <element>.scrollIntoView?
Thanks.

@nothingismagick
Copy link
Contributor

Can this be closed? @hawkeye64

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants