iVantage / angular-ivh-treeview

A treeview for AngularJS with filtering and checkbox support.
http://ivantage.github.io/angular-ivh-treeview/
MIT License
238 stars 89 forks source link

Does not support tristate properly #210

Closed davidfrias closed 7 years ago

davidfrias commented 7 years ago

Hi! It seems tristate functionality is not working properly in the very first load and when you have more than two level in the tree. But after interacting with the tree it works properly.

jtrussell commented 7 years ago

Any chance you have the validate option set to false?

https://github.com/iVantage/angular-ivh-treeview#validate-on-startup

This example demonstrates, nodes with an indeterminate state on startup:

http://jsbin.com/ruxedo/edit?html,js,output

If that doesn't help, maybe you could use the template in our README to provide an example of it not working?

davidfrias commented 7 years ago

I've set the validate to false but it still display the tree wihout tristate behavior.

I made this example: http://jsbin.com/zoqexaroqo/edit?html,js,output

Shouldn't "Fountain" node be with indeterminate state since nodes "two" and "three" are set in false?

Nevertheless when you then click nodes "two" and "three" (to change state to 'false') its parent change to indeterminate state.

jtrussell commented 7 years ago

Validation is top-down. In the example "Fountain" has selected: true and that overrides the initial selected state of it's child nodes. This is due to the interplay between validation being top-down and your default selected state being false - i.e. when we find a node (starting from the root) with a selected state that differs from the default, we assume that's intentional and update the rest of the tree accordingly.

In this specific case you could remove selected: true from "Fountain" and I think it will work as you expect.

davidfrias commented 7 years ago

Ok Thank you!

jtrussell commented 7 years ago

👍