PDA

View Full Version : Load Store with Xml Response



tavinashb
15 Dec 2011, 7:06 AM
Hi,
I am getting following response from server.


<Root>
<TotalRecords>3</TotalRecords>
<Response>
<Status>1</Status>
<Approval>0</Approval>
<Comments>www</Comments>
<CreatedBy>4191</CreatedBy>
<PageNumber>0</PageNumber>
<ParentId>0</ParentId>
<Person>
<Company/>
<CreatedBy>1000</CreatedBy>
<EmailAddress>test@test.com</EmailAddress>
<FirstName>test</FirstName>
<Id>4191</Id>
<LastName>test</LastName>
</Person>
<ReadCountforLoginUser>0</ReadCountforLoginUser>
<ResponseType>3</ResponseType>
</Response>
</Root>

I am trying to load this xml respone in following store -



Ext.define('DataRecord', {
extend: 'Ext.data.Model',
fields: [
{name: 'Id'},
{name: 'FirstName', mapping : 'Person>FirstName'},
{name: 'LastName', mapping : 'PersonLastName'},
{name: 'Status'},
{name: 'Comments'},
{name: 'Approval'},
{name: 'EmailAddress', mapping : 'Person>EmailAddress'},
{name: 'PersonId', mapping : 'Person>Id'},
{name: 'ResponseType', type:'int'}
]
});


var dataStore = new Ext.data.Store({
model: 'DataRecord',
proxy: {
type: 'ajax',
url: "xyz.do"
reader: {
type: 'xml',
root: 'Root',
record: 'Response',
totalProperty: "TotalRecords",
model: 'DataRecord'
}
}
});
But, Store is no getting loaded. Store returns count 0. I am stuck with this. Can you help?

mitchellsimoens
15 Dec 2011, 2:44 PM
Did you execute load() on the store? I just tested your code and it works 100%.

tavinashb
16 Dec 2011, 12:23 AM
Yes, i am executing load() on store. Actually i am loading this from other ext component.


dataStore.load({
params:{
op: 9,
Id: selectedId,
showResponse: true,
start: 0,
limit: 10
}
});


I tried to debug this in detail. While debugging i found out -
reader is returning all records after read but while committing read records
in ext-all-debug.js file on line no. 20113,

clientRecords = me.records;
me.records is undefined.

Can you post your code?

mitchellsimoens
16 Dec 2011, 5:36 AM
Can you post your code?

I used your code and loaded against an XML file. I didn't change anything.

tavinashb
16 Dec 2011, 6:50 AM
For xml file, code works. But, when i use store.load({ params: params}); as i have mentioned in earlier post, code does not work.