我已经实现了ivhtreeview。选择和取消选择都可以正常工作。但是,当我取消选中子节点时,父节点不会被更新为不确定状态,但是父复选框也未被选中。
下面是我的代码,
app.config(['ivhTreeviewOptionsProvider',
function (ivhTreeviewOptionsProvider) {
ivhTreeviewOptionsProvider.set({
defaultSelectedState: true,
validate: true,
});
}])
app.directive('asciiBox', ['ivhTreeviewMgr', 'ivhTreeviewBfs', function (ivhTreeviewMgr, ivhTreeviewBfs) {
return {
restrict: 'AE',
require: '^ivhTreeview',
template: [
'<span class="ivh-treeview-checkbox-wrapper">',
'<input type="checkbox" checked="checked" class="ivh-treeview-checkbox" ng-model="node.selected" ng-change="trvw.select(node, node.selected)"/><label class="checkboxHelper"> </label></span >',
'',
].join('\n'),
link: function (scope, element, attrs, trvw) {
element.on('click', function () {
ivhTreeviewMgr.select(scope.trvw.root(), scope.node, scope.node.selected);
scope.$apply();
});
}
};
}]);
View:
<div class="treeview" ivh-treeview="nodes"
ivh-treeview-expand-to-depth="0"
ivh-treeview-id-attribute="'Code'"
ivh-treeview-label-attribute="'Name'"
ivh-treeview-children-attribute="'children'"
ivh-treeview-node-tpl="tpl"
ivh-treeview-default-selected-state="true" ivh-treeview-selected-attribute="'selected'">
</div>
创建了一个JSBIN,但是其复选框不确定,可以正常工作:( http://jsbin.com/vihomes/edit?html,js,output
如果您看下面的图片,该复选框后面的蓝色背景是我为该复选框定制的样式,这没有反映在上述JSBIN链接中。
如果您观察父节点和子节点的状态,则不确定是否起作用