k12456 2010-10-18 11:24
浏览 261
已采纳

Ext 新new的 data.store对象怎么里面没有值

Ext 新new的 data.store对象怎么里面没有值、

[code="java"]

function getstore(){
var b = new Ext.data.Store( {
id:"bst",
proxy :new Ext.data.HttpProxy( {
url :__ctxPath + "/st/findFormula.do"
}),
reader :new Ext.data.JsonReader( {
root :"result",
totalProperty :"totalCounts",
fields : [ {name :"Id",type :"int"}, "Name" ]
}),
});
b.load()

return b;

}
[/code]
方法返回b之后 b里没有任何值 是空的 但是我确定后台查出来是有json数据的
我现在要获得后台查出来的那些数据怎么办
高人现身吧!

  • 写回答

3条回答 默认 最新

  • lizhiyezi 2010-10-18 13:45
    关注

    设置store proxy 对象,使用同步数据加载。
    proxy:Ext.data.HttpProxy({
    sync : true
    })

    如果使用的是3.0以下可能需要加下面代码设置同步处理

    Ext.lib.Ajax.request = function(method, uri, cb, data, options) {
    if (options) {
    var hs = options.headers;
    if (hs) {
    for (var h in hs) {
    if (hs.hasOwnProperty(h)) {
    this.initHeader(h, hs[h], false);
    }
    }
    }
    if (options.xmlData) {
    if (!hs || !hs['Content-Type']) {
    this.initHeader('Content-Type', 'text/xml', false);
    }
    method = (method ? method : (options.method
    ? options.method
    : 'POST'));
    data = options.xmlData;
    } else if (options.jsonData) {
    if (!hs || !hs['Content-Type']) {
    this.initHeader('Content-Type', 'application/json', false);
    }
    method = (method ? method : (options.method
    ? options.method
    : 'POST'));
    data = typeof options.jsonData == 'object' ? Ext
    .encode(options.jsonData) : options.jsonData;
    }
    }
    return this"sync" in options ? "syncRequest" : "asyncRequest";
    }

    Ext.lib.Ajax.syncRequest = function(method, uri, callback, postData) {
    var o = this.getConnectionObject();

    if (!o) {
        return null;
    } else {
        o.conn.open(method, uri, false);
    
        if (this.useDefaultXhrHeader) {
            if (!this.defaultHeaders['X-Requested-With']) {
                this
                        .initHeader('X-Requested-With', this.defaultXhrHeader,
                                true);
            }
        }
    
        if (postData && this.useDefaultHeader
                && (!this.hasHeaders || !this.headers['Content-Type'])) {
            this.initHeader('Content-Type', this.defaultPostHeader);
        }
    
        if (this.hasDefaultHeaders || this.hasHeaders) {
            this.setHeader(o);
        }
    
        o.conn.send(postData || null);
        this.handleTransactionResponse(o, callback);
        return o;
    }
    

    }

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料