I want to push some field from json object that look like that
{
"type": "tasks",
"levels": 3,
"links": [
{
....
}
],
"assignedDate": "2017-08-02 16:03:36",
"number": 200612,
"priority": 3,
"createdDate": "2017-08-02 16:03:36",
"state": "ASSIGNED",
"ownerRole": "LoanApplication.Process Owner",
"processName": "LoanProcess",
.
.
.
}
in ko.observableArray. this is my JS code (i am using oracle jet )
define(['ojs/ojcore', 'knockout', 'ojs/ojtable'], function (oj, ko) {
function homeContentViewModel() {
var self = this;
self.data = ko.observableArray();
$.getJSON("http://localhost:8085/get/bpm").
then(function (taches) {
$.each(taches, function () {
self.data.push({
title: this.type,
releaseYear: this.levels,
director: this.title
});
});
});
self.dataSource = new oj.ArrayTableDataSource(
self.data,
{idAttribute: 'title'}
);
}
return homeContentViewModel;
});
ps: when i change the JSON object to a JSON array it work Any help is appreciated.
Thanks to @user3297291 this one worked
define(['ojs/ojcore', 'knockout', 'ojs/ojtable'], function (oj, ko) {
function homeContentViewModel() {
var self = this;
self.data = ko.observableArray();
$.getJSON("http://localhost:8085/get/bpm").
then(function (taches) {
self.data.push({
title: this.type,
releaseYear: this.levels,
director: this.title
});
});
self.dataSource = new oj.ArrayTableDataSource(
self.data,
{idAttribute: 'title'}
);
}
return homeContentViewModel;
});