[ 2 posts ]

mlcprs

AutoComplete ignores data from DataSource

Post Posted: Tue Oct 05, 2010 6:50 am
+0-
This post is about how AutoComplete is behaving when returned data from DataSource that has been extracted from an XML file.
I'm new to YUI, and I'm not clear about how DataSource's responseSchema works in terms of which bit gets passed back to AutoComplete.
Perhaps someone can explain in terms of the following simple example.
I have an XML file:

Code:
<bookers>
<record>
<lastName>Abacus</lastName>
<extra> (Polly)</extra>
</record>
<record>
<lastName>Billington</lastName>
<extra> (Sam)</extra>
</record>
</bookers>


and defined (where oDS is the Data Source)
Code:
        oDS.responseSchema = {
           resultNode: 'record',
           fields: ['lastName', 'extra']             
        };

In the debug output I see

DataSource instance0
Parsed XML data is {meta => {}, results => [{extra => (Polly), lastName => Abacus}, {extra => (Sam), lastName => Billington}]}

But (if I type "b") only the lastName fields appear in the AutoComplete results container..
Abacus
Billington

Can anyone say exactly what the relationship is between the responseSchema and the results container?

Thanks
Peter

Matt Parker

YUI Contributor

  • Username: mattatlamplight
  • Joined: Mon Apr 20, 2009 12:03 pm
  • Posts: 466
  • Location: London UK
  • GitHub: mattparker
  • Gists: mattparker
  • Offline
  • Profile

Re: AutoComplete ignores data from DataSource

Post Posted: Fri Oct 08, 2010 3:34 am
+0-
Hi,

The relationship is handled by AutoComplete - that's where you need to handle the data that DataSource is providing. responseSchema only tells the DataSource what to expect, where.

Have a look at this: http://developer.yahoo.com/yui/autocomplete/#formatting - there's some examples there that you should be able to follow to get what you want.

Matt
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum