开发者

How can I override the Ext JS JsonStore timeout?

开发者 https://www.devze.com 2022-12-20 04:37 出处:网络
I have a JsonStore that needs to return from an HTTP request that takes longer than 30 seconds. Setting the \"timeout\" property on either the JsonStore config doesn\'t override the 30-second timeout

I have a JsonStore that needs to return from an HTTP request that takes longer than 30 seconds.

Setting the "timeout" property on either the JsonStore config doesn't override the 30-second timeout, neither does setting a proxy (rather than just setting the url property) and putting a timeout on the proxy.

How can I extend this timeout?

(I'm using Ext JS 3.1.1)

var ds = new Ext.data.JsonStore({
    autoSave:       true,
    method:         "POST",
    /*url:          "search-ajax.aspx",
    timeout:        120000,*/
    root:           "rows",
    totalProperty:  "results",
    idProperty:     "primarykeyvalue",
    proxy:      new Ext.data.HttpProxy({ url: "search-ajax.aspx", timeout: 120000 }),
    fields:     previewColumnConfig,
    baseParams: {
        Command:    "",
        ID:     primaryKeyValue,
        Entity: entityFullName,
        vetype: ValidationEntityType,
        vepk:       ValidationEntityPK,
        now:        (new Date()).getTime()
        },
    writer: new Ext.data.JsonWriter({
        encode:     true,
        listful:    false
     开发者_如何学运维   })
    });


If you want the timeout to be the same across your entire app, set it globally on the Ext.Ajax singleton.

Ext.Ajax.timeout = 120000; //2 minutes

If you want the timeout to be set differently only on a single request, you'll need to define the HttpProxy in a var and modify one of it's properties before passing it into the JsonStore config. The conn property takes options to be used for that request only.

var proxy = new Ext.data.HttpProxy({ url: "search-ajax.aspx" });
proxy.conn = { timeout: 120000 };


without defining the proxy or the connection in a var

proxy:      new Ext.data.HttpProxy(
              new Ext.data.Connection({
                          url: "search-ajax.aspx",
                          timeout: 120000 })),


You can define:

var proxy1 = new Ext.data.HttpProxy(
        { 
            url: 'yourUrl',
            reader: {
                    type: 'json',
                    root: 'items',
                    totalProperty: 'total'
                }
        });
proxy1.timeout = 600000; 

It include reader in proxy


I know this question is old but wanted to add override option I found that works in ExtJS 4.2.2

Ext.override(Ext.data.proxy.Ajax, { timeout: 120000 });

I completed the override in the Application init however, i think you could complete this override anywhere prior to the request.

Additionally, if you are using JsonP this override works for me:

Ext.data.proxy.JsonP.timeout = 120000;
0

精彩评论

暂无评论...
验证码 换一张
取 消