I am facing an issue for oj-table.
I have defined my oj-table data variables as below.
self.classesPolicyDataArray = ko.observableArray();
self.classesDataForPolicyDataProvider = new ArrayDataProvider(self.classesPolicyDataArray, {keyAttributes: 'id'});
format of classData = [
{ "id" : 1
.... }
{
}
]
when I try to update a table row accroding to the line,
self.classesPolicyDataArray.splice(data.index,1,data.row);
I am getting error
Uncaught TypeError: Cannot read property '0' of undefined
at ko.subscription.callback (ojarraydataprovider.js:427)
at Function.notifySubscribers (knockout-3.4.2.debug.js:1330)
at Function.target.notifySubscribers (knockout-3.4.2.debug.js:1769)
at ko.subscription.callback (knockout-3.4.2.debug.js:1791)
at Function.notifySubscribers (knockout-3.4.2.debug.js:1330)
at Function.target.notifySubscribers (knockout-3.4.2.debug.js:1769)
at Function.valueHasMutated (knockout-3.4.2.debug.js:1548)
at Function.ko.observableArray.fn.<computed> [as splice] (knockout-3.4.2.debug.js:1697)
at QosPolicyClassesModel.self.updateClassArrayWhenTypeChanged (classes.js:49)
at ojknockout.js:2259
I have debugged ojarraydataprovider.js file and it's failing on line ` var key = self._getKeys()[changes[i].index];'
for (i = 0; i < changes.length; i++) {
if (updatedIndexes.indexOf(i) >= 0) {
var key = self._getKeys()[changes[i].index];
// By this time, updatedIndexes contains indexes of "added" entries in "changes" array that
// have matching "deleted" entries with same keys, which should be the same as the old keys.
keyArray.push(key);
dataArray.push(changes[i].value);
indexArray.push(changes[i].index);
}
}
Can anyone help with this?