Although standard Flex 3 DataGrid implements findString() function it is not really usable. Searching only the first column or the column with sorting enabled is definitely not intuitive and skipping to the next match on every keystroke is confusing. Furthermore calling to findString() changes selected index without highlighting matching text so in DataGrid with many columns it may be hard to figure out where the matching text is located.
Given above I decided to create new more flexible and reusable searching mechanism for DataGrid. As I was working on it I realized that other components (e.g. TextArea) may also support searching. That’s why I decided to create ISearchable interface to be implemented by every component supporting searching.
I also decided that searching should support standard wildcards like “*” or “?” so I created WlidcardUtils class to convert wildcards to regular expressions which are internally used by my searching mechanism. I know that regular expressions aren’t very fast so maybe one day I will write my own mechanism for matching wildcards but for now RegExp’s are enough.
To support searched text to be highlighted I have implemented BoldSearchItemRenderer which can be used instead of standard DataGridItemRenderer.
Finally I have extended DataGrid to implement ISearchable interface. I haven’t named it SearchableDataGrid since I am going to add many other features later and as AdvancedDataGrid name was in use too I decided to leave the name DataGrid changing only the package.