我坚持与执行以下操作:获取嵌套数组取决于下拉选择,使之可观察
的逻辑如下:取决于用户选择的形式,获得与此相关的表格所有部分。例如:如果用户选择名称为“T-01”的表格,那么章节数组必须填写与该表格相关的所有章节。并且每个部分必须是可观察的以便进一步计算。
这里是我的表单模型:
function Form(name, title, max, total, sections) {
this.Name = ko.observable(name);
this.Title = ko.observable(title);
this.MAX = ko.observable(max);
this.Total = ko.observable(total);
this.Sections = ko.observableArray(sections);
this.addSection = function() {
this.Sections.push(new Section());
}.bind(this);
}
var FormOptions = ko.observableArray(['T-01', 'T-02', 'T-03']);
而且这里的部分型号:
function Section(section, criteria, is, cs, nc, fc, totalInitialScores, totalFinalScores) {
this.Section = ko.observable(section);
this.Criteria = ko.observable(criteria);
this.IS = ko.observable(is);
this.CS = ko.observable(cs);
this.NC = ko.observable(nc);
this.FC = ko.observable(fc);
this.TotalInitialScores = ko.observable(totalInitialScores);
this.TotalFinalScores = ko.observable(totalFinalScores);
}
我有一个根级别的几个型号,但我不包括在这里,不知道如果需要的话。