方法如下:

ImportOrderItem = function (grid) {
    var fromStore = grid.getStore();
    if(grid.isNew){
        Ext.Ajax.request({
            url: OfficeService + '/QueryItem',
            scope: this,
            success: function (response) {
                fromStore = response.responseXML;
        });
    }
    // do something with fromStore
}


在外面formstore的值永远是grid.getStore()的值,因为Ajax请求是异步的。



参考:

http://www.sencha.com/forum/showthread.php?27277-return-ajax.request-result

http://stackoverflow.com/questions/10915974/extjs-how-to-memorize-a-response-from-an-ajax-request

http://stackoverflow.com/questions/4506655/javascript-variable-scope