0
我的问题的foreach大选择地变慢knockoutjs数据绑定
我有一个加载同一选择有数以百计的检索每个数据项的选项表。我检索数据的选择和之前的数据绑定其存储在一个JavaScript变量。问题是,因为有这么多的选择,选项花费10秒来填充数据集有200多个项目。
我所做的决定,这是我已经删除了选择非常快的数据绑定的运行,所以我敢肯定,这是我的问题,发现问题
。
我的问题
我还能做些什么来加速这一进程?
我实现
<table id="reportList">
<tbody data-bind='foreach: reportList'>
<tr>
<td>
<select class="itemSelect" data-bind="options: $root.selectItemIDOptions,
value:ItemID, optionsValue: 'ItemID',
optionsText: 'SupplierItemID',
optionsCaption: 'Select Item'" />
</td>
<td data-bind="text: Description"></td>
</tr>
我的视图模型
function ReportViewModel(reportData) {
//GlobalItemList already has all of the select options at this point ready for databinding
self.selectItemIDOptions = GlobalItemList;
self.reportList = ko.observableArray();
var Shrinkage = reportData.ShrinkageList;
var rowArr = self.reportList();
for (var i = 0; i < Shrinkage.length; i++) {
rowArr.push(new ReportRow(Shrinkage[i].ItemID, Shrinkage[i].Description);
}
self.reportList.valueHasMutated();
}
Row类
function ReportRow(ItemID, Description) {
var self = this;
self.ItemID = ko.observable(ItemID);
self.Description = ko.observable(Description);
}
这里类似的问题:http://stackoverflow.com/questions/9709374/knockout-js-incredibly-slow-under-semi-large-datasets – SkelDave 2014-11-04 21:48:05