vto*_*mak 6 scope extjs extjs-stores
this.loadSmt = function(argPanel)
{
this.store1 = new Ext.data.JsonStore({
url : 'URL1',
totalProperty : 'total',
successProperty : 'success',
root : 'root1',
fields : [
{name: 'data1'},
{name: 'data2'}
]
});
this.store2 = new Ext.data.JsonStore({
url : 'URL2',
totalProperty : 'total',
successProperty : 'success',
root : 'root2',
fields : [
{name: 'data21'},
{name: 'data22'},
{name: 'data23'},
{name: 'data24'},
{name: 'data25'}
]
});
this.store1.on('beforeload', function() {
this.store1.baseParams = {
argID: myID
};
}, this);
this.store2.load({
callback : function() {
var graphOwner = argPanel;
var graphDataArr = [];
var i = 0;
this.data.each(function(item, index, totalItems) {
var data1 = item.data['data1'];
var data2 = item.data['data2'];
// create arraystore data for graph
var tempArr = new Array();
tempArr.push(data1);
tempArr.push(data2);
graphDataArr[i] = tempArr;
i++;
});
this.GraphPanel = this.getMyGraph(graphDataArr);
}
}, this);
};
this.getMyGraph = function(argGraphValue)
{
// do something
}
Run Code Online (Sandbox Code Playgroud)
当我运行这段代码时,我得到了
TypeError:this.getMyGraph不是函数
错误,当我使用
this.data.each
函数在商店回调,我不能使用
this.getMyGraph
功能.我认为这是一个范围问题,如何将作为参数的范围传递给函数或如何修复此错误?
你通过范围的方式是对的.您需要使用加载选项的范围参数.
this.store2.load({
callback : function(records, operation, success) {
...
},
scope: this
});
Run Code Online (Sandbox Code Playgroud)
http://docs.sencha.com/ext-js/4-1/#!/api/Ext.data.Store-method-load
| 归档时间: |
|
| 查看次数: |
5357 次 |
| 最近记录: |