Closed armellarcier closed 8 years ago
+1
There's no explicit option for changing the baked in selection strategy. If you want simple (i.e. non-propagating) selection the easiest thing is to swap out the ivh-treeview-checkbox
directive in your template with a vanilla checkbox + ngModel.
I found an easy solution to make that an option and created a PR #125
Is there a compelling reason not to use the strategy I mentioned above? Disabling your recursive selection option basically turns ivhTreeview checkboxes into regular ones (if I'm reading the changes correctly) but with more overhead and at the cost of extra complexity to the directive as a whole.
I needed recursive selection to be an option the user could turn on and off easily. As I'm using angular material, I'm calling the 'select' method from a custom directive with an option object with 'recursiveSelection' either true or false. I don't know if that's a compelling reason though. Just pretty straightforward.
Would it be possible to call ivhTreeviewMgr.select
when recursive selection is desired, and if not simply set the node's selected
property in your custom directive? You can grab that property name from ivhTreeviewOptions
to be fully generic, as well as the indeterminate property if you need it.
While I agree with the OP @Benew that this would be a good feature, for completeness here are code samples for how to accomplish this via @jtrussell's suggestion.
<div ivh-treeview="...">
<script type="text/ng-template">
<span ng-if="trvw.useCheckboxes()">
<input class="ivh-treeview-checkbox"
ng-model="node.isSelected"
type="checkbox">
</span>
</script>
</div>
Note that if you are not using the default isSelected
property, you will need to bind to your particular property.
<div ivh-treeview="..."
ivh-treeview-selected-attribute="'IsSelectedCustom'">
<script type="text/ng-template">
<span ng-if="trvw.useCheckboxes()">
<input class="ivh-treeview-checkbox"
ng-model="node.IsSelectedCustom"
type="checkbox">
</span>
</script>
</div>
How to make recursive selection an option? Is that possible? I can't find the code responsible for that...
Thanks in advance!