Dec 17, 2014, 1:17 PM
[OPEN] [#619] Error when return StoreResult's Success set to false
On the following example, step to page 2. ExampleController.LoadFakeRecords will return StoreResult with Success set to false. This will cause the following error:
AjaxProxy is trying to call ExampleController.LoadFakeRecords again, without the correct parameters.
it's possible to see that ExampleController.LoadFakeRecords is being called again if its signature is replaced by the following:
AjaxProxy is trying to call ExampleController.LoadFakeRecords again, without the correct parameters.
<!DOCTYPE html>
<html>
<head id="Head1" runat="server">
</head>
<body>
<ext:ResourceManager runat="server" ScriptMode="Debug" />
<ext:GridPanel Title="Ext.Net" Width="500" Height="500" runat="server">
<Store>
<ext:Store AutoLoad="true" runat="server">
<Proxy>
<ext:AjaxProxy Url="/Example/LoadFakeRecords/" StartParam="start" LimitParam="limit" PageParam="page" SortParam="sort">
<ActionMethods Read="POST" />
<Reader>
<ext:JsonReader RootProperty="data" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Model>
<ext:Model IDProperty="ID" runat="server">
<Fields>
<ext:ModelField Name="ID" />
<ext:ModelField Name="Name" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel runat="server">
<Columns>
<ext:Column Text="ID" DataIndex="ID" runat="server" />
<ext:Column Text="Name" DataIndex="Name" runat="server" />
</Columns>
</ColumnModel>
<BottomBar>
<ext:PagingToolbar DisplayInfo="true" runat="server" />
</BottomBar>
</ext:GridPanel>
</body>
</html>
namespace SandBox.Controllers
{
public class ExampleController : System.Web.Mvc.Controller
{
public ActionResult Index()
{
return View();
}
public StoreResult LoadFakeRecords(int start, int limit, int page, string sort)
{
if (page == 2)
{
return new StoreResult
{
Success = false,
Message = "Failed"
};
}
else
{
List<Person> lst = new List<Person>();
for (int index = start; index < (page * limit); index++)
{
lst.Add(new Person
{
ID = index,
Name = "Name" + index
});
}
return new StoreResult(lst, (page * limit) + limit);
}
}
}
[Serializable]
public class Person
{
public int ID { get; set; }
public string Name { get; set; }
}
}
it's possible to see that ExampleController.LoadFakeRecords is being called again if its signature is replaced by the following:
public StoreResult LoadFakeRecords(Nullable<int> start, Nullable<int> limit, Nullable<int> page, string sort)
Then we get:- start: -25
- limit: 25
- page: null
- sort: null
Last edited by Daniil; Dec 22, 2014 at 12:24 PM.
Reason: [OPEN] [#619]