, , . -
parentCheckBox observable self.parentChildData.self.parentChildData.children -.parentCheckBox computed observable.
, , , , parentCheckBox , self.parentChildData.children, , , , .
, self.parentChildData.children , parentCheckBox computedObservable ( , ).
self.parentChildData.parentCheckBox = ko.computed({
read: function() {
var anyChildUnChecked = ko.utils.arrayFirst(self.parentChildData.children(), function(childCheckBox) {
return !childCheckBox.isSelected();
});
var result = anyChildUnChecked == null;
return result;
},
write: function(value) {
ko.utils.arrayForEach(self.parentChildData.children(), function(childCheckBox) {
childCheckBox.isSelected(value);
});
}
});
self.parentChildData.children(childrenArray);
, self.makeDependent, , , self.parentChildData.children , computed : -)
fiddle.