Nov 15, 2013, 6:59 PM
Cannot get data in store in client side
I have Ext:Store defined in aspx page. and on page_load I assign datasource to it and bind to datasource. I steped in the code and make sure there is data in datasource. but in the client side I cannot get data in the store. Can you take a look at the code if there are anyting wrong?
Server side code in Page_Onload:
Server side code in Page_Onload:
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("PageID", typeof(int)));
dt.Columns.Add(new DataColumn("PageUrl", typeof(string)));
dt.Columns.Add(new DataColumn("FileName", typeof(string)));
dt.Columns.Add(new DataColumn("BatchNumber", typeof(string)));
dt.Columns.Add(new DataColumn("IsDocumented", typeof(bool)));
dt.Columns.Add(new DataColumn("CreatedDate", typeof(DateTime)));
dt.Columns.Add(new DataColumn("PageCount", typeof(int)));
dt.Columns.Add(new DataColumn("FileExt", typeof(string)));
dt.Columns.Add(new DataColumn("CreatedBy", typeof(string)));
dt.Columns.Add(new DataColumn("DocumentBy", typeof(string)));
dt.AcceptChanges();
List<PagesWrapper> showPages = PagesWrapper.FindAllByDocIDandTypeNoLock(GetDocumentID(), GetFileType());
if (showPages.Count > 0)
{
initPageID = showPages[0].PageID;
}
int pageid = 0;
foreach (PagesWrapper page in showPages)
{
//BindPagerInfo(page);
DataRow dr = dt.NewRow();
dr["PageID"] = page.PageID;
dr["PageUrl"] = "";
dr["FileName"] = page.FileName;
dr["BatchNumber"] = page.BatchNumber;
dr["IsDocumented"] = page.IsDocumented;
dr["CreatedDate"] = page.CreatedDate;
dr["FileExt"] = page.FileExt;
dr["CreatedBy"] = page.DisplayCreateBy;
dr["DocumentBy"] = page.DisplayDocumentedBy;
if (page.PageCount == null && page.PageCount == 0)
{
try
{
dr["PageCount"] = DocumentsWrapper.CalculatePageSize(page.FileExt, page.GetFileContent(), DotImageDocumentProcessor.GetDocumentProcessor());
}
catch (Exception ex)
{
dr["PageCount"] = 1;
}
}
else
{
dr["PageCount"] = page.PageCount;
}
dt.Rows.Add(dr);
//}
}
dt.AcceptChanges();
storePageData.DataSource = dt;
storePageData.DataBind();
on client side page code:<ext:Store ID="storePageData" runat="server">
<Model>
<ext:Model runat="server" IDProperty="PageID">
<Fields>
<ext:ModelField Name="PageID" Type="Int"/>
<ext:ModelField Name="PageUrl" Type="String" />
<ext:ModelField Name="FileName" Type="String" />
<ext:ModelField Name="BatchNumber" Type="String" />
<ext:ModelField Name="IsDocumented" Type="Int" />
<ext:ModelField Name="CreatedDate" Type="Date" DateFormat="M/d hh:mmtt" />
<ext:ModelField Name="PageCount" Type="Int" />
<ext:ModelField Name="FileExt" Type="String" />
<ext:ModelField Name="CreatedBy" Type="String" />
<ext:ModelField Name="DocumentBy" Type="String" />
</Fields>
</ext:Model>
</Model>
<Parameters>
<ext:StoreParameter Name="pageid" Mode="Raw" Value="document.getElementById('pageid').value">
</ext:StoreParameter>
</Parameters>
</ext:Store>
client side java script code, I debug into code App.storePageData.getCount(); get 0, even it has data bind in page_load. and return App.storePageData.getById(pagerID); returned null value. function GetCurrentPage() {
var pagerID = document.getElementById("pageid").value;
var count = App.storePageData.getCount();
return App.storePageData.getById(pagerID);
}