richardtallent
richardtallent

Reputation: 35374

How can I override the Ext JS JsonStore 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
        })
    });

Upvotes: 16

Views: 29553

Answers (4)

weeksdev
weeksdev

Reputation: 4355

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;

Upvotes: 2

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

Upvotes: 2

Joram
Joram

Reputation: 3246

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 })),

Upvotes: 12

Jonathan Julian
Jonathan Julian

Reputation: 12264

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 };

Upvotes: 36

Related Questions