Created
December 15, 2010 18:37
-
-
Save squeedee/742388 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0"?> | |
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" xmlns:flextras="http://www.flextras.com/mxml/" layout="vertical"> | |
<mx:Script><![CDATA[ | |
import com.flextras.autoCompleteComboBox.AutoCompleteCollectionEvent; | |
import mx.collections.ArrayCollection; | |
private function handleFilter(event:AutoCompleteCollectionEvent):void { | |
event.preventDefault(); | |
bruteForceServerRequest(AutoCompleteComboBox(event.target).typeAheadTextValue); | |
} | |
// this one isnt as elegant as mine | |
private function bruteForceServerRequest(searchTerm:String):void { | |
dp.removeAll(); | |
var searchRE:RegExp = new RegExp("/" + searchTerm + "/"); | |
PRETEND_SERVER.forEach( | |
function(item:*, index:int, array:Array):void { | |
if (String(item.name).search(searchRE)) | |
dp.addItem(item); | |
} | |
); | |
} | |
[Bindable] | |
public var dp:ArrayCollection = new ArrayCollection(); | |
private const PRETEND_SERVER:Array = [ | |
{name:"Customer_1"}, | |
{name:"Customer_2"}, | |
{name:"Customer_3"}, | |
{name:"Customer_4"}, | |
{name:"Customer_5"}, | |
{name:"Customer_6"}, | |
{name:"Customer_7"}, | |
{name:"Customer_8"}, | |
{name:"Customer_9"}, | |
{name:"Customer_10"}, | |
{name:"Customer_11"}, | |
{name:"Customer_12"}, | |
{name:"Customer_13"}, | |
{name:"Customer_14"}, | |
{name:"Customer_15"}, | |
{name:"Customer_16"}, | |
{name:"Customer_17"}, | |
{name:"Customer_18"}, | |
{name:"Customer_19"} | |
] | |
]]></mx:Script> | |
<mx:Label text="DP Length: {dp.length}" /> | |
<flextras:AutoCompleteComboBox | |
dataProvider="{dp}" | |
width="200" | |
labelField="name" | |
downArrowVisible="false" | |
autoCompleteEnabled="true" | |
autoCompleteSelectOnSpecial="true" | |
autoCompleteHighlightOnFocus="true" | |
autoCompleteDataProviderFilterBegin="{handleFilter(event)}" | |
/> | |
</mx:Application> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment