简体   繁体   English

flex 3和autoComplete

[英]flex 3 and autoComplete

im trying to getting auto complete working and i can do so fine when i just create an array in my mxml and then just initialize an arrayCollection at the top of the file in the initialize keyword. 我试图自动完成工作,当我在mxml中创建一个数组,然后在initialize关键字的文件顶部初始化一个arrayCollection时,我可以做得很好。

However i want to populate the arraycollection from a webservice but i cant seem to get it; 但是我想从Web服务中填充arraycollection,但是我似乎无法得到它。

im my application tag i have the following 我的应用程序标签中有以下内容

creationComplete="init()"
initialize="data2 = new ArrayCollection(data1);" 

then in my init method; 然后用我的init方法;

    private function init():void 
{
userRequest.loadWSDL(wsdlUrl);
userRequest.getAllCountries();
}   

//this is called when i get a result from userRequest.getAllCountries(); //当我从userRequest.getAllCountries()获得结果时调用此方法;

 private function getAllCountriesResult(e:ResultEvent):void 
    {
    data1 = new Array(e.result);
        }

however my text box is not getting any value. 但是我的文本框没有任何价值。

Anyone with ideas? 任何有想法的人吗?

first off, Array is not Bindable so changing the variable data1 will have no knock on effect. 首先,Array是不可绑定的,因此更改变量data1将不会产生连锁反应。

The arrayCollection is bindable. arrayCollection是可绑定的。

So presumming that the result (e.result) is actually an array (you should check this when debugging) then you could do the following 因此,假设结果(e.result)实际上是一个数组(调试时应检查此数组),则可以执行以下操作

[Bindable]
priavte var ac : ArrayCollection;

then inside you're getAllCountriesResult function. 然后在里面是getAllCountriesResult函数。

ac = new ArrayCollection(e.result);

then anything that has is dataprovider set to the var ac will be updated. 然后已将dataprovider设置为var ac的所有内容都将更新。

If you wish to update a text value inside a textArea or similar then you should listen for the change event in the arrayCollection and take the appropriate action then. 如果要更新textArea或类似文本内的文本值,则应侦听arrayCollection中的change事件,然后采取适当的措施。


from your additional points below (just edit your original question) 从下面的其他要点开始(只需修改您的原始问题)

I take it the autocomplete your talking about is the autocomplete text input box from adobe exchange area as a normal text box doesn't take an arrayCollection. 我认为您所说的自动完成功能是Adobe交换区域的自动完成功能文本输入框,因为普通的文本框不使用arrayCollection。 If you posted some code it may make it easier to help you. 如果您发布了一些代码,则可以更轻松地为您提供帮助。 Preinitialize, then initialize, then creationComplete, then applicationComplete (this is the order they get called in). 预初始化,然后初始化,然后creationComplete,然后applicationComplete(这是它们被调用的顺序)。

If your using the component I'm thinking of, check out http://www.websector.de/blog/2008/04/30/quick-tip-avoid-issues-using-adobes-autocomplete-input-component-using-flex-3/ It appears it may have some issues with flex 3, so check out http://blogs.adobe.com/flex/2006/09/component_autocomplete_text_in.html . 如果您使用的是我正在考虑的组件,请查看http://www.websector.de/blog/2008/04/30/quick-tip-avoid-issues-using-adobes-autocomplete-input-component-using -flex-3 /似乎flex 3可能存在一些问题,因此请查看http://blogs.adobe.com/flex/2006/09/component_autocomplete_text_in.html

Try this: 尝试这个:

private function getAllCountriesResult(e:ResultEvent):void 
{
   data2.source = new Array(e.result); // or data2.source = e.result as Array
}

Make sure data2 is already initialized as a ArrayCollection. 确保已将data2初始化为ArrayCollection。

As for AutoComplete, I'm trying to work things out myself. 至于自动完成,我正在尝试自己解决问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM