我在我的代码中使用淘汰赛 observables。
我的代码看起来像这样
self.allAggs = ko.observableArray();
self.aggregatedDataSource = ko.observable( new oj.ArrayTableDataSource(self.allAggs, {idAttribute: 'itemName'}) );
self.aggregatedDataSource.subscribe(function(value) {
console.log('Value changed for aggregatedDataSource');
console.log(ko.toJS(value));
});
要插入数据,我使用下面的代码
self.allAggs(newdata);
我这里有两个问题:
- 作为 newdata 的一部分传递给 self.allAggs 的数据与 UI 上显示的数据不同。
HTML 代码如下所示:
<div id="aggregationContainer" data-bind="visible: isVisibleContainer($element.id)" class="blk" style="display:none;">
<table id="aggTable" class="amc-full-width-table amc-max-height-table"
data-bind="ojComponent: {component: 'ojTable',
data: aggregatedDataSource,
display: 'grid',
columnsDefault: {sortable: 'enabled'}, columns: [
{headerText: $data.l10n_default('desktop-management.toolbar.option.',$data.selectedReportType()), field: 'itemName'},
{headerText: oj.Translations.getTranslatedString('desktop-management.report.column.hostCount'), renderer: hostCountRenderer, sortProperty: 'hostCount'}],
rootAttributes: {class:'amc-full-width-table'},
sort: $data.onVersionTableSort}">
</table>
</div>
- 该控件永远不会进入订阅功能。
请帮助我了解我在哪里做错或遗漏了什么。