PDA

View Full Version : Dataview not displaying data from DirectStore



pezze
28 Jan 2010, 3:35 PM
I'm trying to use a Dataview with a DirectStore but unfortunately no data is displaying.

Here it is my code:


var storeCompany = new Ext.data.DirectStore({
autoLoad: false,
directFn: DirectContacts.GetContact,
paramsAsHash: false,
idProperty: 'id',
fields: [
'id',
'companyName',
'category',
'websiteAddress',
'emailAddress',
'address',
'zip',
'city',
'province',
'country',
'phoneNumber',
'faxNumber'
],
root: 'contact',
paramsNames: { contactId: 'contactId' },
paramOrder: 'contactId'
});

var companyTpl = new Ext.Template(
'<tpl for=".">',
'<div class="contact-wrap">',
'<p>Societ&agrave;: <b>{companyName}</b></p>',
'<p>&nbsp;</p>',
'<p>Categoria: {category}</p>',
'<p>SitoWeb: {websiteAddress}</p>',
'<p>Email: <a href=\'mailto:{emailAddress}\'>{emailAddress}</a></p>',
'<p>Indirizzo:</p>',
'<p>{address}</p>',
'<p>{zip} {city} {province}</p>',
'<p>{country}</p>',
'<p>Telefono: {phoneNumber}</p>',
'<p>Fax: {faxNumber}</p>',
'</div>',
'</tpl>'
);

var dvCompany = new Ext.DataView({
store: storeCompany,
tpl: companyTpl,
emptyText: 'Selezionare un contatto',
itemSelector: 'div.contact-wrap',
loadingText: 'Attendere prego...',
multiSelect: false,
singleSelect: false
});

dvCompany.store.load({ params: { contactId: 1 } });


And here it is the data after calling the store.load function:


[{"type":"rpc","tid":4,"action":"DirectContacts","method":"GetContact","result":{"contact":{"id":0,"companyName":"OBO BETTERMANN GmbH & Co.","category":"Elettrico automotive","phoneNumber":"+4902373890","faxNumber":"+490237389238","emailAddress":"[email protected]","websiteAddress":"http://www.obo-bettermann.com/de/","address":"Hüingser Ring 52","city":"Menden","zip":"58710","province":"","country":"Germany"},"success":true,"description":"","error":""}}]

Can you help me please?
Thanks

evant
28 Jan 2010, 9:01 PM
Does the store ever get loaded?

pezze
29 Jan 2010, 12:17 AM
Does the store ever get loaded?

Yes the store is correctly loaded when a user choose a value from a combox:


dvCompany.store.load({ params: { contactId: 1 } });

I used value 1 instead of real value for semplicity.

I see loadingText in the Dataview, then I see the template but without any values.

pezze
29 Jan 2010, 8:45 AM
I've found the solution.

I've used


Ext.XTemplate

instead of


Ext.Template