I want to use the value of var ajaxRe
which is in the ajax request success,
outside the ajax request, but the value is undefined
. I want to use the response to load data in a grid,
Ext.Ajax.request({
url : myUrl,
params : {
myParamList
},
success : function(re,action) {
var ajaxRe = re.responseText;
...
var respArr = ..;
},
failure : function(form,action) {
console.log("fail");
}
});
when I print grid.getStore()
within success, the grid contains the data I need, but it is not being displayed,
I am setting data in the grid's store within success, and accessing the grid outside.
success : function(re,action) {
that.editorGrid.getStore().data = respArr;
}
How can I solve this?
Thanks
If data is in correct format try below
that.editorGrid.getStore().loadData(respArr);
If you want apply proxy reader to load data use
that.editorGrid.getStore().loadRawData(respArr);
One other way is to reconfigure store and bind that store to grid
var store = Ext.create('Model', {
autoLoad: true,
data: responseJson,
proxy: {
type: 'memory',
reader: {
type: 'json'
}
}
});
that.editorGrid.bindStore(store);