PDA

View Full Version : Data Store Returns No cached record.



gbembio2002
23 Jan 2011, 3:46 PM
Everytime I try to run the getCount() for the datastore I get Zero even though there is a record in the XML file

*****************JavaScript Extjs*********************************
Ext.onReady(function () {
var DataFields = new Ext.data.Record.create([//record for mapping data from XML File
{
name: "Author",
mapping: "Author"
},
{
name: "Author",
mapping: "Author"
},
{
name: "Manufacturer",
mapping: "Manufacturer"
},
{
name: "ProductGroup",
mapping: "ProductGroup"
}
]);

var DataXmlReader = new Ext.data.XmlReader({ record: "Item" }, DataFields); //XML READER uses "Item" as the Record to go through in the XML file

var DataProxyAddress = new Ext.data.HttpProxy({
url: "http://localhost:47483/Responder.aspx"//Return XML stream with content Type: text/xml
});


var DataStoreSection = new Ext.data.Store({//Data store variable
autoLoad: true,
proxy: DataProxyAddress,
reader: DataXmlReader
});

alert(DataStoreSection.getCount());//Shows how many data records were retrieved. It somehow generates zero every time :(


});


**************************http://localhost:47483/Responder.aspx.cs*****************************

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Web.UI.WebControls;

namespace Respond
{
public partial class Respond : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
HttpContext.Current.Response.ClearContent();
HttpContext.Current.Response.ContentType = "text/xml";
TextReader tr = new StreamReader("C:\\inetpub\\wwwroot\\SampleData.xml");
HttpContext.Current.Response.Output.Write(tr.ReadToEnd());
tr.Close();
HttpContext.Current.Response.End();
}
}
}


**********************SampleData.xml***************************


<?xml version="1.0" encoding="UTF-8"?>
<Items>
<Item>
<ASIN>0446613657</ASIN>
<DetailPageURL>
http://www.amazon[*SNIP*]JVQEG2
</DetailPageURL>
<ItemAttributes>
<Author>Sidney Sheldon</Author>
<Manufacturer>Warner Books</Manufacturer>
<ProductGroup>Book</ProductGroup>
<Title>Are You Afraid of the Dark?</Title>
</ItemAttributes>
</Item>
</Items>