PDA

View Full Version : Getting dynamic XML file parsed correctly as result to a search



h32Lg
9 Jun 2011, 2:10 AM
Hi,

i need to search articles via a form. This is done with SearchForm.js. (JSONP as. scripttag proxy) But how to get the response parsed correctly into the SearchResults.js? (both files are provided as attachment)

The response XML can look like this:

<articles>
<article>
<articleNumber>2837492</articleNumber>
<patternId>2349</patternId>
<saisonId>325</saisonId>
<catalogueType>53</catalogueType>
<workSite>4532</workSite>
<countryCode>DE</countryCode>
<languageCode>de</languageCode>
<description>Beschreibung 1</description>
<salesBrandCode>264</salesBrandCode>
<salesBrandLanguageCode>de</salesBrandLanguageCode>
<salesBrandDescription>Brand Beschreibung 1</salesBrandDescription>
<color>rot</color>
<image>bild1.jpg</image>
<articleGroup>53</articleGroup>

</article>



</articles>


Each article can have multiple saisonId's. They will be presented as seperate article! When changing the saisonId in the dropdown box on the results pane, the corresponding article should be parsed into the fields immediately and automatically.

SearchResults.js already has some example values to show what it should look like :)

Can you please help me to get this problem solved fast?
It is a blocker for our company.

Thanks in advance
René

h32Lg
9 Jun 2011, 2:31 AM
I've also written a model and a store:

Model:

Ext.regModel('Article', {
fields: [
{name: 'articleNumber', type: 'string'},
{name: 'patternId', type: 'string'},
{name: 'saisonId', type: 'int'},
{name: 'catalogueType', type: 'int'},
{name: 'workSite', type: 'int'},
{name: 'countryCode', type: 'string'},
{name: 'languageCode', type: 'string'},
{name: 'description', type: 'string'},
{name: 'salesBrandCode', type: 'int'},
{name: 'salesBrandLanguage', type: 'string'},
{name: 'salesBrandDescription', type: 'string'},
{name: 'color', type: 'string'},
{name: 'image', type: 'string'},
{name: 'articleGroup', type: 'int'}
]
});

Store:

var articleStore = new Ext.data.Store({
model: 'Article',
storeId: 'articleStore',

proxy: {
type: 'scripttag',
url : 'http://uri-to-retrieve-the-xml-response-from',
reader: {
type: 'xml',
root: 'articles'
}
},

autoLoad: false
});