The same versatility we saw with Store Proxies in Chapter 5, Working with Data, applies to grids too, so that we can load the preceding financial data from an MVC Controller, ASMX Web Service, ASHX handler, and more. The following is an example of ASHX handler:
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "application/json"; Paging<CompanyData> data = this.GetData(); context.Response.Write(JSON.Serialize(data)); } private Paging<CompanyData> GetData() { var data = CompanyData.GetData(); return new Paging<CompanyData>(data, data.Count); }
And the following is the only modification needed to the Store to use the handler:
<ext:Store runat="server">
<Model>
<!-- as before -->
</Model>
<Proxy>
<ext:AjaxProxy Url="../Shared/FinancialData.ashx">
<Reader>
<ext:JsonReader Root="data" />
</Reader>
</ext:AjaxProxy>
<...