No More Posting New Topics!

If you have a question or an issue, please start a thread in our Github Discussions Forum.
This forum is closed for new threads/ topics.

Navigation

    Quasar Framework

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search

    QTree Filter By Things Other Than A String

    Help
    2
    2
    140
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • E
      ejackson last edited by

      I have a QTree which implements the normal string filter pattern per the documentation.
      I’d like to add some toggles outside of the QTree, to show/hide certain elements based on custom properties in the QTree’s nodes.

      For example, suppose I have this node structure:

      2020
      — Alice
      — Bob
      2021
      — Alice
      — Bob

      I can use the text filter to successfully search for Alice or Bob. I’d like the toggles to show or hide all of 2021, 2020, etc. Note, this is simplified data.

      Having looked at the QTree implementation on GitHub, I can see it is checking if the Filter string is non-empty, before calling the filter function (per https://github.com/quasarframework/quasar/blob/684ed9fbe5320552d69ee32393a305205894fd8c/ui/src/components/tree/QTree.js#L140 )

      So, the question is - is there any way people can think of where I can convince the QTree to respond to toggles when the filter string is blank?

      In particular, where the filter is blank, I can force the Qtree to filter on my toggles by setting the filter string to something programmatically, and then applying a custom filter function. The problem is when it is cleared again, the function is not applied and all filtering is removed.

      Thanks,
      Ed

      1 Reply Last reply Reply Quote 0
      • I
        Ilia last edited by Ilia

        Generate the tree in the way when you store the key in each node containing the label of each parent that node has (e.g. parent2-key/parent1-key/node-key). Then, in the filter-method=“filterMethod” you will be able to use node.key.indexOf(filterVal) to return bool

        Not the best approach, but given the circumstances of using just q-tree, that’s probably the best way I can think of 🙂
        Let me know if you need an example

        1 Reply Last reply Reply Quote 0
        • First post
          Last post