Reputation: 2023
I am new to ivh tree (https://github.com/iVantage/angular-ivh-treeview) and using this library. I want to disable to certain nodes for selection, based on user entitlement
for example i have tree like this
$scope.bag = [{
label: 'Glasses',
value: 'glasses',
entitled: false,
children: [{
label: 'Top Hat',
value: 'top_hat',
entitled: true
}, {
label: 'Curly Mustache',
value: 'mustachio',
entitled: false
}]
}];
};
So based on variable entitled: [boolean], it should let user select or unselect. how can this be done?
Upvotes: 0
Views: 1205
Reputation: 695
To accomplish this you'll need to put some logic into a custom node template. Here's a stripped down example where I've introduced a helper directive that just inspects the node
scope value and disables its checkbox if needed.
http://jsbin.com/buqaxu/2/edit?html,js,output
app.directive('isCbEnabled', function() {
return {
link: function(scope, element, attrs) {
if(scope.node.disabled) {
element.find('input').attr('disabled', true);
}
}
};
});
You'd could attach something like this to your the ivh-treeview-checkbox
directive in your template. Note that node
is a supported scope variable within templates.
Upvotes: 2