PDA

View Full Version : empty store



Robert82
17 Feb 2010, 1:54 AM
hello guys,

I have a problem with my store. I use the data property, but the store is empty.
The code of the store looks like the following


var store = new Ext.data.XmlStore({
autoDestroy: true,
autoLoad: true,
storeId: 'myXmlStore',
data: myData,
record: 'document',
fields: ['abstract']
});


and the data ins an js object xmlDocument



var xml = '<?xml version="1.0"?><abstract>This is my test string</abstract>';
var myData = (new DOMParser()).parseFromString(xml, "text/xml");


Can anyone help me? I have no idea :((
I use this in a local environment only one html file and the js file.

Eugen_
17 Feb 2010, 2:20 AM
hi Robert,

Maybe



var xml = '<?xml version="1.0"?><document><abstract>This is my test string</abstract></document>';

tobiu
17 Feb 2010, 2:21 AM
hi Robert82,

why do you use autoLoad, if you set the data manually?

kind regards,
tobiu

Robert82
17 Feb 2010, 6:00 AM
Hello,

@Eugen_
if I use var xml instead of var xmlData nothing happen. I thought the XmlReader needs a Document with a xml header.

@tobiu
Uh, I have deleted autoLoad, but nothing happens. The store is empty.


Blimey :((

goldledoigt
17 Feb 2010, 6:43 AM
Hi,

this works:


var xml = '<?xml version="1.0" ?><xxx><document><abstract>This is my test string</abstract></document></xxx>';

var myData = (new DOMParser()).parseFromString(xml, "text/xml");

var store = new Ext.data.XmlStore({
autoDestroy: true,
autoLoad: true,
storeId: 'myXmlStore',
data: myData,
record: 'document',
fields: ['abstract']
});

Robert82
17 Feb 2010, 7:21 AM
yeah - thanks. It seems that I should read more about the record-property within the xmlStore.

Big Thanks :)

EDIT: Is it possible to read a XML file like this?


var xml = '<?xml version="1.0" ?><abstract>This is my test string</abstract>';

This is not possible

var storeXML = new Ext.data.XmlStore({
autoDestroy: true,
autoLoad: true,
storeId: 'myXmlStore',
data: data,
record: 'abstract',
fields: ['abstract']
});