オプションリストにノックアウトデータバインディングを使用した選択リストがあります。ビューがロードされても何も表示されませんが、リストがバインドされている obevablearray DDABankNums にデータがあります。
これが私の選択リストです-
<select id="Select1" style="margin-top: 0px; height: 24px; width: 160px !important"
data-bind="value: DDABankNums().LoanNum, optionsText: DDABankNums().AccountName, optionsCaption: 'Select...', optionsValue: DDABankNums().LoanNum">
</select>
ビューモデルコード-
define(['services/logger', 'durandal/system', 'durandal/plugins/router', 'services/CertificateDataService'],
function (logger, system, router, CertificateDataService) {
var allCertificates = ko.observableArray([]);
var myCertificates = ko.observableArray([]);
var isSelected = ko.observable();
var serverSelectedOptionID = ko.observable();
var filter = ko.observable(0);
var CertificateDetails = ko.observableArray([]);
var DDABankNums = ko.observableArray([]);
var CertificateDetailsToShow = ko.computed(function () {
GetCertificateDetails();
return ko.utils.arrayFilter(CertificateDetails(), function (CertD) {
return CertD.CertificateID == filter();
});
});
var serverOptions = [
{ id: 1, name: 'Certificate', OptionText: 'lwCertID' },
{ id: 2, name: 'Client Name', OptionText: 'clientName' },
{ id: 3, name: 'Client Number', OptionText: 'clientNumber' },
{ id: 4, name: 'Request Date', OptionText: 'requestDate' },
{ id: 5, name: 'Collateral Analyst', OptionText: 'userName' }
];
var activate = function () {
// go get local data, if we have it
return SelectAllCerts(), SelectMyCerts(), CertificateDetailsToShow(), GetDDABankNums();
};
var vm = {
activate: activate,
ResetFilter: ResetFilter,
filter: ko.observable(),
allCertificates: allCertificates,
myCertificates: myCertificates,
CertificateDetails: CertificateDetails,
CertificateDetailsToShow: CertificateDetailsToShow,
DDABankNums: DDABankNums,
title: 'Certificate Approvals',
SelectMyCerts: SelectMyCerts,
SelectAllCerts: SelectAllCerts,
theOptionId: ko.observable(1),
serverOptions: serverOptions,
serverSelectedOptionID: serverSelectedOptionID,
SortUpDownAllCerts: SortUpDownAllCerts,
isSelected: isSelected,
selectThing: function (row, event) {
filter(row.lwCertID);
isSelected(row.lwCertID);
}
};
serverSelectedOptionID.subscribe(function () {
var sortCriteriaID = serverSelectedOptionID();
allCertificates.sort(function (a, b) {
var fieldname = serverOptions[sortCriteriaID - 1].OptionText;
if (a[fieldname] == b[fieldname]) {
return a[fieldname] > b[fieldname] ? 1 : a[fieldname] < b[fieldname] ? -1 : 0;
}
return a[fieldname] > b[fieldname] ? 1 : -1;
});
});
return vm;
function GetDDABankNums() {
return CertificateDataService.getDDABankNums(DDABankNums);
}
function ResetFilter() {
filter(0);
isSelected(false);
}
function GetCertificateDetails() {
return CertificateDataService.getCertDetails(CertificateDetails);
}
function SortUpDownAllCerts() {
allCertificates.sort();
}
function SelectAllCerts() {
return CertificateDataService.getallCertificates(allCertificates);
}
function SelectMyCerts() {
return CertificateDataService.getMyCertificates(myCertificates);
}
});
リストが表示されないのはなぜですか?