khan4019 / tree-grid-directive

Need one or more maintainer for this! comment or email me if you are interested
http://khan4019.github.io/tree-grid-directive/test/treeGrid.html
347 stars 183 forks source link

Show children after filtering #138

Open SoftCreatR opened 7 years ago

SoftCreatR commented 7 years ago

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 commented 7 years ago

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

SoftCreatR commented 7 years ago

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 commented 7 years ago

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:

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 commented 7 years ago

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

torsten-sauer commented 7 years ago
...
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 commented 7 years ago

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 commented 7 years ago

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...