Apr 12, 2012, 7:21 PM
[CLOSED] Handle errors when loading store´s data
The following example throws an exception when Store is loading. I would like to know the correct way to handle the error for avoiding "Internal Server Error" exception.
I have some questions about the process of loading store´s data
I have some questions about the process of loading store´s data
- In version 2.0 the listener LoadException of the store was removed and there is just the Exception listener, is it correct?
- why can´t i set the Success and ErrorMessages of properties of the StoreResult (StoreResponseData)?
- I would also like to know which is the correct way to handle an exception when loading the store´s data.
- Do i have to implement a custom class to accomplish it?
<ext:GridPanel ID="GridPanel1" runat="server" Width="700" Height="500" Title="ExtJS.com - Browse Forums">
<Store>
<ext:Store ID="Store1" runat="server" PageSize="30" RemoteSort="true" AutoLoad="true">
<Proxy>
<ext:AjaxProxy Url="/Example/Test/">
<Reader>
<ext:JsonReader Root="data" TotalProperty="total" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model ID="Model1" runat="server">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
<Listeners>
<Exception Handler="alert('error')" />
</Listeners>
</ext:Store>
</Store>
<ColumnModel ID="ColumnModel1" runat="server">
<Columns>
<ext:Column ID="Column1" runat="server" Text="ID" DataIndex="ID" />
<ext:Column ID="Column2" runat="server" Text="Name" DataIndex="Name" />
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server" TrackOver="false" LoadMask="true">
</ext:GridView>
</View>
<BottomBar>
<ext:PagingToolbar runat="server" />
</BottomBar>
</ext:GridPanel>
public StoreResult Test(int start, int limit)
{
throw new Exception("Message");
StoreResult response = new StoreResult();
List<Person> data = new List<Person>();
Random randow = new Random();
DateTime now = DateTime.Now;
for (int i = start + 1; i <= start + limit; i++)
{
Person p = new Person()
{
ID = i,
Name = "name " + i,
};
data.Add(p);
}
response.Data = data;
response.Total = 50000;
return response;
}
Last edited by Daniil; May 07, 2012 at 3:14 PM.
Reason: [CLOSED]