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

Show children after filtering #138

Open
SoftCreatR opened this issue Apr 2, 2017 · 7 comments
Open

Show children after filtering #138

SoftCreatR opened this issue Apr 2, 2017 · 7 comments

Comments

@SoftCreatR
Copy link

Currently, nodes are shown until the matching node.

But if the matching node is a node with children, it appears to be expandable but it isn't. Nothing happens when clicking the expand icon. That's possibly some kind of a bug. However, displaying the children could be absolutely intended (as it is in my case, for example).

So i would ask you to implement the possibility to (optionally) display the children of a found parent node.

@torsten-sauer
Copy link

Could you try if https://github.com/khan4019/tree-grid-directive#expanding-tree-after-search fits your needs?

@SoftCreatR
Copy link
Author

That isn't, what i am looking for (i already use it). It just defines, if parent nodes are expanded when searching for a child node but it.

@torsten-sauer
Copy link

Hmm... Ah, I think now I understand what you like to do: you want to display child nodes that don't match the current filter, but their parent do?

Without changing the code you could try following:

  • add a hidden column to the nodes that contains the (filterable) data from the parent
  • make this colum filterable

That should work. I used this "hack" for searching hidden data inside my nodes (had a title, short description, long description but only title was visible - but wanted to search all three)

@SoftCreatR
Copy link
Author

Do you have an example? I'm not sure, if i understand that correctly or how that could work to achieve this.

@torsten-sauer
Copy link

torsten-sauer commented Apr 2, 2017

  • create a colum with
    • a name that doesn't collide with existing fields
    • a displayNameof " " (a single space, if you leave it blank the name will be used!)
    • a cellTemplate with an empty tag (span e.g.)
    • filterable should be true
  • when setting your tree data, you have to make sure, that every children that should open the way you descriped has the parent data inside the name you choose
...
tree_data = [
  { Name: "p1", filterMe: "Hello", filterMe2: "World", children: [ { Name: "c1", parentFilter: "Hello World", filterMe: "Foo", filterMe2: "Bar"}]
]

col_defs = {
...
      {
            field: "parentFilter",
            displayName: " ",
            filterable: true,
            cellTemplate: "<span>&nbsp;</span>"
        },
...
}

Hope you get the idea^^

@SoftCreatR
Copy link
Author

Okay, that could be an idea. But it fails when having this:

{ Name: "p1", filterMe: "Hello", filterMe2: "World", filterMe3: "Boo", children: [ { Name: "c1", parentFilter: "Hello World", filterMe: "Foo", filterMe2: "Bar", filterMe3: "Baz"}]

When now searching for Boo, children are are ommitted, because the parentFilter-property doesn't contain this word.

To make this work properly (without changing the directive), i would have to concat all parent properties into a single string and add it as new property to the children. Correct?

@torsten-sauer
Copy link

Yes, that would be the way to go.

Currently the search works as a filter for ng-repeat, so every node that doesn't fit the filter criteria is discarded - so will be the children in your case. Changing this behaviour would need a bigger rewrite...

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

2 participants