I wrote a custom data provider that will filter results from a wrapped DataProvider. The idea was that you could plug in different filters; filter on partially typed words, location etc.
This custom data provider (FilterDataProvider) extends the mx.control.listclasses.DataProvider class. I'm running into two problems and the solutions to those problems allude me. The first is that my DataGrid is not receiving modelChanged events that my FilterDataProvider fires. The second is that my DataGrid is not setting the selectedItem property when I click on a row. It also does not highlight the row that I clicked. Here is the code from my FilterDataProvider (I've removed some of the extraneous function calls for brevity/readability). The important thing to note is that the FilterDataProvider receives events from its configured filters indicating that something about them has changed and they need to refilter the data. These events are received by the filterDataProvider, which in turn fires off a modelChanged event. I've confirmed that the FilterDataProvider is indeed receiving events from its configured filters (alerting out messages), and I've also confirmed that the DataGrid that this filterDataProvider is configured on never receives the modelChanged event. (I extended the DataGrid class and overrode the modelChanged method, alerted out a message before calling super.modelChanged) Any help is appreciated. Thanks! class FilterDataProvider extends DataProvider { public var source : DataProvider; public var filters : Array; public function get length():Number { var sourceLength:Number = mSource.length; var filteredLength : Number = 0; for (var i:Number = 0; i < sourceLength; i++) { var item = mSource.getItemAt(i); if (accept(item)) { filteredLength++; } } return filteredLength; } public function getItemAt(pIndex:Number) { var sourceLength:Number = mSource.length; for (var i:Number = pIndex + mOffset; i < sourceLength; i++) { var item = mSource.getItemAt(i); if (accept(item)) { return item; } } return null; } private function accept(pItem) : Boolean { var filterLength:Number = mFilters.length; for (var i:Number = 0; i < filterLength; i++) { var filter:Filter = mFilters[i]; if (!filter.accept(pItem)) { return false; } } return true; } public function processFilterChangedEvent(pEvent:Object) { var eventObject : Object; eventObject.type = "modelChanged"; eventObject.eventName = "updateAll"; dispatchEvent(eventObject); } } mxml registration... <components:FilterDataProvider source="{remoteObject.result}" id="filterProvider"/> <components:FancyDataGrid id="videoGrid" width="100%" height="100%" dataProvider="filterProvider"> -ashley Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/flexcoders/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/