【发布时间】:2017-09-20 11:52:54
【问题描述】:
这个变量可以在 onContext 函数中访问,但我想将获取的 ajax json 结果分配给网格的存储对象。 grid 是像 gride:{store:"some-Json"} 这样的对象
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 是第一个首先调用的方法,然后是onContext 方法调用.. 这个词在该函数中可用,this 变量具有 this.grid 属性,在 @987654325 中无法访问 this.grid 属性@.Properties 在xhr.get() 中更改。我想在 xhr.get() 函数中访问 this 的所有属性。因为我想将我的 ajax json 结果分配给this.grid.store 和this.grid.params.store 属性
【问题讨论】:
标签: javascript dojo dojox.grid.datagrid aps