Re: Searching in a list of values (menulist, textbox)

Michael Hofer <[email protected]>
Newsgroups gmane.comp.mozilla.devel.xpfe
Message-ID <[email protected]>
Am 26.01.12 12:35, schrieb Michael Hofer:
> I want the user to be able to search and select a value from a
> predefined list. I'm using an editable menulist with a menupopup for
> this at the moment:
[...]
> An option could be to write a custom autocomplete textbox (like
> described on
> https://developer.mozilla.org/en/How_to_implement_custom_autocomplete_search_component).
> But is it possible do get the ids of the entries into that? How do I get
> the id of the 'selected' element?

I played around with the textbox autocomplete a bit. I can use objects 
as array-elements (containing the displayValue and the id):

ProviderAutoCompleteResult.prototype.getValueAt = function(index) {
     return this.results[index]['id'];
};

ProviderAutoCompleteResult.prototype.getLabelAt = function(index) {
     return this.results[index]['displayValue'];
};

This way the labels (displayValue) are displayed as autocomplete 
suggestions, but when the user selects an entry the value (id) gets 
filled into the textbox.

Not exactly what I want. Any ideas how to access/store the id of the 
selected entry for later retrieval (while displaying the displayValue)? 
Is there a way to access the textbox from within the 
'ProviderAutoCompleteResult' (nsIAutoCompleteResult) to attach something 
like a 'selectedId' attribute to it?

Thanks for your help!

regards,
Michael
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.