如何覆盖 Ext JS JsonStore 超时?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2253592/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I override the Ext JS JsonStore timeout?
提问by richardtallent
I have a JsonStore that needs to return from an HTTP request that takes longer than 30 seconds.
我有一个 JsonStore,它需要从耗时超过 30 秒的 HTTP 请求中返回。
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.
在 JsonStore 配置上设置“超时”属性不会覆盖 30 秒超时,也不会设置代理(而不仅仅是设置 url 属性)并在代理上设置超时。
How can I extend this timeout?
如何延长此超时时间?
(I'm using Ext JS 3.1.1)
(我使用的是 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
})
});
回答by Jonathan Julian
If you want the timeout to be the same across your entire app, set it globally on the Ext.Ajaxsingleton.
如果您希望整个应用程序的超时时间相同,请在Ext.Ajax单例上全局设置它。
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 HttpProxyin a var and modify one of it's properties before passing it into the JsonStoreconfig. The connproperty takes options to be used for that request only.
如果您希望仅在单个请求上设置不同的超时,则需要HttpProxy在 var 中定义并在将其传递到JsonStore配置之前修改其属性之一。该conn属性采用仅用于该请求的选项。
var proxy = new Ext.data.HttpProxy({ url: "search-ajax.aspx" });
proxy.conn = { timeout: 120000 };
回答by Joram
without defining the proxy or the connection in a var
无需在 var 中定义代理或连接
proxy: new Ext.data.HttpProxy(
new Ext.data.Connection({
url: "search-ajax.aspx",
timeout: 120000 })),
回答by án Bình Tr?ng
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
它包括代理中的阅读器
回答by weeksdev
I know this question is old but wanted to add override option I found that works in ExtJS 4.2.2
我知道这个问题很旧但想添加我发现在ExtJS 4.2.2中有效的覆盖选项
Ext.override(Ext.data.proxy.Ajax, { timeout: 120000 });
I completed the override in the Application inithowever, i think you could complete this override anywhere prior to the request.
init但是,我在应用程序中完成了覆盖,我认为您可以在request.
Additionally, if you are using JsonP this override works for me:
此外,如果您使用的是 JsonP,则此覆盖对我有用:
Ext.data.proxy.JsonP.timeout = 120000;

