PDA

View Full Version : [CLOSED] GridPanel loading from ASHX handler 2.0



rthiney
Jan 10, 2013, 5:18 PM
hi,
I have a grid:

<ext:GridPanel runat="server" ID="grid" Height="400" Header="true" Title="Companies" AutoDataBind="true"> <Store>
<ext:Store
ID="gridCo"
runat="server"
RemoteSort="true" AutoDataBind="true">
<Proxy>
<ext:AjaxProxy Url="../Handler/GetCompanies.ashx">
<ActionMethods Read="GET" />
<Reader>
<ext:JsonReader Root="data" TotalProperty="total" />
</Reader>
</ext:AjaxProxy>
</Proxy>
<Parameters>
<ext:StoreParameter Name="query" Value="8" />
</Parameters>
<Model>
<ext:Model ID="storeCompanies" runat="server">
<Fields>
<ext:ModelField Name="PortfolioCompanyId" Type="Int" />
<ext:ModelField Name="CompanyName" Type="String" />
<ext:ModelField Name="FiscalDate" Type="Date" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</Store>
<ColumnModel>
<Columns>
<ext:Column ID="Column31" runat="server" Text="ID" DataIndex="PortfolioCompanyId" />
<ext:Column ID="Column2" runat="server" Text="CompanyName" DataIndex="CompanyName" />
<ext:Column ID="Column3" runat="server" Text="FiscalDate" DataIndex="FiscalDate" />
</Columns>
</ColumnModel>
<View>
<ext:GridView ID="GridView1" runat="server">
</ext:GridView>
</View>
</ext:GridPanel>


being loaded by:


public void ProcessRequest(HttpContext context) {
context.Response.ContentType = "text/json";


try
{


string query = string.Empty;
if (!string.IsNullOrEmpty(context.Request["query"]))
{
int fundId = -1;
int.TryParse(context.Request["query"], out fundId);
var data = (from pc in PortfolioCompany.All()
join pf in PortfolioCompanyFund.All() on pc.PortfolioCompanyId equals pf.PortfolioCompanyId
where pf.FundId == fundId
select new { PortfolioCompanyId = pc.PortfolioCompanyId, CompanyName = pc.CompanyName, FiscalDate = pc.FiscalDate }).ToList();


context.Response.Write(string.Format("{{totalCount:{1},'result':{0}}}", JSON.Serialize(data), data.Count));
}
}
catch { }






}
I can verify that the handler returns data, but I'm not seeing it the grid. I'm sure its a silly gridpanel configuration...

Here is the return stream from the handler:


{totalCount:86,'result':[{"PortfolioCompanyId":1,"CompanyName":"Bausch & Lomb Incorporated","FiscalDate":"2005-12-31T00:00:00"},{"PortfolioCompanyId":3,"CompanyName":"Nuance Communications Inc","FiscalDate":"2012-11-05T00:00:00"},{"PortfolioCompanyId":9,"CompanyName":"7 Days Group Holdings Limited","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":16,"CompanyName":"Amtek Auto Limiteds","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":19,"CompanyName":"AU Financiers (India) Private Limited","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":20,"CompanyName":"Banco Indusval + Partners","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":21,"CompanyName":"Bascom","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":23,"CompanyName":"Beijing Tianyu Communications","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":24,"CompanyName":"Benchmark Solutions, Inc. (fka Julius Finance)","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":25,"CompanyName":"Black Swan","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":26,"CompanyName":"Brack Capital Real Estate","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":31,"CompanyName":"CASA Exploration","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":33,"CompanyName":"Century SJTL Holdings Ltd.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":37,"CompanyName":"China Resources Retail JV","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":38,"CompanyName":"Clondalkin","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":41,"CompanyName":"Constitution Medical Investors, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":43,"CompanyName":"Cortview","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":44,"CompanyName":"Covenant Group","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":46,"CompanyName":"Datong","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":47,"CompanyName":"Delonex Energy","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":49,"CompanyName":"Dili Group Holdings Company Limited (Hada)","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":50,"CompanyName":"Diliigent Power Private Limited","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":51,"CompanyName":"Dumpling King","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":52,"CompanyName":"Endurance","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":53,"CompanyName":"Endurance Energy","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":55,"CompanyName":"Evidon, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":56,"CompanyName":"Explora Petroleum AS","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":57,"CompanyName":"Extant Components Group Holdings, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":58,"CompanyName":"FacilitySource","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":59,"CompanyName":"Fairfield Energy Limited","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":62,"CompanyName":"Flexuspine","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":64,"CompanyName":"Gangavaram Port Ltd.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":67,"CompanyName":"Greentown","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":70,"CompanyName":"Harbin Pharmaceuticals Group (Hayao)","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":72,"CompanyName":"Hawkwood Energy","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":74,"CompanyName":"Hotel Derek","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":76,"CompanyName":"InComm","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":78,"CompanyName":"Interactive Data Corporation","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":79,"CompanyName":"Intime","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":82,"CompanyName":"ITC","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":83,"CompanyName":"Keystone Dental","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":85,"CompanyName":"Kosmos Energy LLC","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":87,"CompanyName":"Laredo Petroleum","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":93,"CompanyName":"MEG Energy Corp.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":95,"CompanyName":"Mingfa","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":96,"CompanyName":"MultiView","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":97,"CompanyName":"National Penn","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":98,"CompanyName":"Neiman Marcus Group","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":102,"CompanyName":"OnTargetJobs","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":104,"CompanyName":"PhotoThera","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":106,"CompanyName":"PowerWind","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":107,"CompanyName":"Premier Foods","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":108,"CompanyName":"Primerica","FiscalDate":"2008-05-07T00:00:00"},{"PortfolioCompanyId":109,"CompanyName":"Punj Lloyd","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":111,"CompanyName":"Quikr","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":112,"CompanyName":"RCS China","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":113,"CompanyName":"RDA Microelectronics Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":116,"CompanyName":"Regional Diagnostic Labs","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":118,"CompanyName":"Renhe Commercial Holdings Company Limited","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":120,"CompanyName":"Resolution II Holdings (Jersey) Limited","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":123,"CompanyName":"SafetyKleen Europe","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":126,"CompanyName":"Sasseur","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":127,"CompanyName":"Scotsman Industries, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":128,"CompanyName":"Service Repair Solutions","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":130,"CompanyName":"Silk Road Medical","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":131,"CompanyName":"Sophiris Bio","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":132,"CompanyName":"Spigit","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":133,"CompanyName":"Sterling Financial Corporation","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":134,"CompanyName":"Stratford School","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":136,"CompanyName":"Sunnywell Group (Omega)","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":137,"CompanyName":"Sunshine 100 Real Estate Co. Ltd","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":139,"CompanyName":"Synutra International, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":141,"CompanyName":"Targa Resources","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":143,"CompanyName":"Tianjin Weiman Biomaterial Co., Ltd. (PWM)","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":144,"CompanyName":"Times Property","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":148,"CompanyName":"TradeCard, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":150,"CompanyName":"Triton Container","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":151,"CompanyName":"Triyar","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":154,"CompanyName":"VALUATIONS TEST DEAL","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":156,"CompanyName":"Venari","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":157,"CompanyName":"WARP Funding Company Ltd","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":158,"CompanyName":"West Valley Energy","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":162,"CompanyName":"Xueda","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":163,"CompanyName":"Yodlee, Inc.","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":165,"CompanyName":"Zhejiang Weixin Bio-pharma","FiscalDate":"2012-01-01T00:00:00"},{"PortfolioCompanyId":166,"CompanyName":"Ziggo B.V. / Multikabel-Casema","FiscalDate":"2012-01-01T00:00:00"}]}

Daniil
Jan 10, 2013, 6:19 PM
Hi @rthiney,

According the response you should set up:

<ext:JsonReader Root="result" TotalProperty="totalCount" />
or otherwise replace

context.Response.Write(string.Format("{{totalCount:{1},'result':{0}}}", JSON.Serialize(data), data.Count));
with

context.Response.Write(string.Format("{{total:{1},'data':{0}}}", JSON.Serialize(data), data.Count));

rthiney
Jan 11, 2013, 4:36 PM
Yup! That did it!