PDA

View Full Version : [CLOSED] How can i set the timeout to a store in a user control?



JCarlosF
May 10, 2013, 12:31 AM
How can i set the timeout to a store in a user control?
probe with this code:


<script type="text/javascript">
Ext.Ajax.timeout = 120000;
Ext.net.DirectEvent.timeout = 120000;
</script>


but did not work 30 seconds after connection failure message is shown
thanks

Baidaly
May 10, 2013, 1:10 AM
Hello!

Can you provide test case to reproduce? Do you load UserControl in another Frame or to the same page?

Daniil
May 10, 2013, 4:06 AM
Hi,

You can also ensure the code is executed.

<script type="text/javascript">
alert("I am here.");
Ext.Ajax.timeout = 120000;
Ext.net.DirectEvent.timeout = 120000;
</script>

JCarlosF
May 10, 2013, 2:15 PM
Hi,

You can also ensure the code is executed.

<script type="text/javascript">
alert("I am here.");
Ext.Ajax.timeout = 120000;
Ext.net.DirectEvent.timeout = 120000;
</script>




is in the same page and the alert is working what can i try ?

RCN
May 10, 2013, 2:49 PM
In addition:


Ext.Ajax.timeout = 3600000;
Ext.override(Ext.form.Basic, { timeout: Ext.Ajax.timeout / 1000 });
Ext.override(Ext.data.proxy.Server, { timeout: Ext.Ajax.timeout });
Ext.override(Ext.data.Connection, { timeout: Ext.Ajax.timeout });

Daniil
May 10, 2013, 2:56 PM
Yes, setting a timeout for a Ext.data.proxy.Server should help in your case. If it doesn't, please provide a test case.

Raphael, thank you for the contribution!

RCN
May 10, 2013, 4:29 PM
Going further:



Store str = new Store();
AjaxProxy ajxProxy = new AjaxProxy
{
Timeout = 3600000
};
str.Proxy.Add(ajxProxy);

RCN
May 10, 2013, 4:31 PM
Raphael, thank you for the contribution!

You're welcome

JCarlosF
May 10, 2013, 4:41 PM
Yes, setting a timeout for a Ext.data.proxy.Server should help in your case. If it doesn't, please provide a test case.

Raphael, thank you for the contribution!

I tested with


<head id="Head1" runat="server" >
<script type="text/javascript">
Ext.net.DirectEvent.timeout = 120000;
Ext.Ajax.timeout = 3600000;
Ext.override(Ext.form.Basic, { timeout: Ext.Ajax.timeout / 1000 });
Ext.override(Ext.data.proxy.Server, { timeout: Ext.Ajax.timeout });
Ext.override(Ext.data.Connection, { timeout: Ext.Ajax.timeout });
</script>
</head>

but does not work after 30 seconds the message appears some other option??

RCN
May 10, 2013, 4:58 PM
Please post a complete (but simplified) code sample demonstrating how to reproduce the issue.

JCarlosF
May 10, 2013, 5:37 PM

RCN
May 10, 2013, 5:51 PM
The following example works as expected. Take a look on Controller at line 12, the Thread sleeps for 5 minutes before return the result.

Let me know whether it helps you

1 - View


<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
<title>Index</title>
<script type="text/javascript">
Ext.Ajax.timeout = 3600000;
Ext.override(Ext.form.Basic, { timeout: Ext.Ajax.timeout / 1000 });
Ext.override(Ext.data.proxy.Server, { timeout: Ext.Ajax.timeout });
Ext.override(Ext.data.Connection, { timeout: Ext.Ajax.timeout });
</script>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server" />
<ext:Panel ID="Panel1" Margin="10" Header="false" runat="server">
<Items>
<ext:GridPanel ID="GridPanel1" runat="server" Title="Records" Frame="false" Width="300">
<Store>
<ext:Store runat="server" ID="Store2">
<Proxy>
<ext:AjaxProxy Timeout="3600000" Url="/Example/LoadFakeRecords/">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="ID" Type="String" />
<ext:ModelField Name="Name" Type="String" />
<ext:ModelField Name="Address" Type="String" />
</Fields>
</ext:Model>
</Model>
<Sorters>
<ext:DataSorter Property="Common" Direction="ASC" />
</Sorters>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:RowNumbererColumn ID="RowNumbererColumn1" runat="server" />
<ext:Column ID="Column1" runat="server" Text="ID" DataIndex="ID" />
<ext:Column ID="Column3" runat="server" Text="Name" DataIndex="Name" />
<ext:Column ID="Column2" runat="server" Text="Address" DataIndex="Address" />
</Columns>
</ColumnModel>
</ext:GridPanel>
</Items>
</ext:Panel>
</body>
</html>


2 - Controller and Utility


namespace SandBox.Controllers
{
public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}

public StoreResult LoadFakeRecords()
{
Thread.Sleep(TimeSpan.FromMinutes(5));

List<Person> lst = new List<Person>();

for (int index = 0; index < 15; index++)
{
lst.Add(new Person
{
ID = index,
Name = "Name" + index,
Address = "Address" + index,
});
}

return new StoreResult(lst, lst.Count());
}
}

public class Person
{
public int ID { get; set; }

public string Name { get; set; }

public string Address { get; set; }
}
}

RCN
May 10, 2013, 5:53 PM
You also have to set the timeout inside Comparativo.ascx

JCarlosF
May 10, 2013, 6:56 PM
ok i am adding this code on each store in comparativo.ascx is this right ??



<Proxy>
<ext:AjaxProxy Timeout="5000">
</ext:AjaxProxy>
</Proxy>

RCN
May 10, 2013, 7:07 PM
Yes. It is. Please note that 5000 means 5 seconds

Daniil
May 13, 2013, 5:15 AM
Well, an AjaxProxy's Timeout should work for sure.

But this should work as well.

Ext.override(Ext.data.proxy.Server, { timeout: 60000 });

It appears to be working in the test case below.

Page

<%@ Page Language="C#" %>

<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<%@ Register Src="~/TestUC.ascx" TagPrefix="uc" TagName="TestUC" %>

<!DOCTYPE html>
<html>
<head runat="server">
<title>Ext.NET v2 Example</title>

<script>
Ext.override(Ext.data.proxy.Server, { timeout: 60000 });
</script>
</head>
<body>
<form runat="server">
<ext:ResourceManager runat="server" />
<uc:TestUC runat="server" />
</form>
</body>
</html>


User Control

<%@ Control Language="C#" %>

<%@ Register TagPrefix="ext" Namespace="Ext.Net" Assembly="Ext.Net" %>

<ext:GridPanel ID="GridPanel1" runat="server">
<Store>
<ext:Store runat="server">
<Model>
<ext:Model runat="server">
<Fields>
<ext:ModelField Name="test1" />
<ext:ModelField Name="test2" />
<ext:ModelField Name="test3" />
</Fields>
</ext:Model>
</Model>
<Proxy>
<ext:AjaxProxy Url="GetData.ashx">
<Reader>
<ext:ArrayReader />
</Reader>
</ext:AjaxProxy>
</Proxy>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column runat="server" Text="Test1" DataIndex="test1" />
<ext:Column runat="server" Text="Test2" DataIndex="test2" />
<ext:Column runat="server" Text="Test3" DataIndex="test3" />
</Columns>
</ColumnModel>
</ext:GridPanel>

GetData.ashx

using System;
using System.Collections.Generic;
using System.Web;
using Ext.Net;

namespace Work2
{
public class GetData : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
System.Threading.Thread.Sleep(40000);
context.Response.ContentType = "application/json";
context.Response.Write(JSON.Serialize(new object[]
{
new object[] { "test1", "test2", "test3" },
new object[] { "test4", "test5", "test6" },
new object[] { "test7", "test8", "test9" }
})
);
}

public bool IsReusable
{
get
{
return false;
}
}
}
}

JCarlosF
May 13, 2013, 8:47 PM
I still have the same problem, the ajax url is required in ajax proxy?

Baidaly
May 13, 2013, 10:50 PM
I still have the same problem, the ajax url is required in ajax proxy?

Yes, you should set Url for Ajax proxy because this proxy loads data using AJAX requests.

However, have you tried Daniil's sample? Does it work for you?

JCarlosF
May 13, 2013, 11:12 PM
Yes, you should set Url for Ajax proxy because this proxy loads data using AJAX requests.

However, have you tried Daniil's sample? Does it work for you?


ok thanks for the info, I filled the store in the code behind so I do not need the reader is correct?



<Proxy>
<ext:AjaxProxy Url="Comparativo.ascx.vb" timeout="5000">
</ext:AjaxProxy>
</Proxy>

Baidaly
May 14, 2013, 2:24 AM
ok thanks for the info, I filled the store in the code behind so I do not need the reader is correct?

You should define Reader for the Proxy