I am using knockout observables in my code.
My code looks like this
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));
});
To insert data I am using below code
self.allAggs(newdata);
I have two issues here:
- The data passed to self.allAggs as part of newdata is different than what is displayed on UI.
HTML code looks like this:
<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>
- The control never goes inside subscribe function.
Please help me understanding where I am doing wrong or missing something.