this variable is accessible in the onContext function but I want to assign fetched ajax json result to grid's store object. grid is the object like gride:{store:"some-Json"} like example
define([
"dojo/_base/declare",
"dojo/when",
"aps/_View",
"aps/xhr"
], function(
declare,
when,
_View,
xhr
) {
var page, grid, self, contextId,myResult,samp;
return declare(_View, {
init: function() {
self = this;
return ["aps/Grid", {
id: "srv_grid",
selectionMode: "multiple",
columns: [{
field: "id",
name: "Id"
}]
},
];
}, // End of Init
onContext: function(context) {
this.grid = this.byId("srv_grid"); //working
xhr.get("/aps/2/resources/" + aps.context.vars.device.aps.id + "/getresource").
then(function(data){
myResult=data;
this.grid.params.store=data; //got error here this.grid is undefined
this.grid.store=data; //got error here this.grid is undefined
}
),
this.grid.refresh();
},
}); // End of Declare
}); // End of Define
init is the first method that calls first, then onContext method call.. this word is available in that function and this variable has this.grid property that this.grid property is not accessible in xhr.get().Properties of this are changed in xhr.get(). I want to access all the properties of this inside xhr.get() function. Because I want to assign my ajax json result to this.grid.store and this.grid.params.store property
you can use
or
'this' always gives you the property or objects in that context. So in your case inside xhr.get, you are able to access everything that available as part of xhr but anything outside of it is not accessible.