16
Jun
09

FLEX Datagrid header with a ComboBox Filter

Ever wanted to have a ComboBox on datagrid header to filter the datas?

Most of the results found on net were disappointing. Since they just provided a solution to place the ComboBox  on datagrid header. The basic step was to override the setter function data in ComboBox class which is intended to be the DataGridHeader Renderer

override public function set data(value:Object):void
{
	if(value is DataGridColumn)
	{
		//Don't do anything
	}
        else
	{
		super.data = value
	}
}

Unfortunately, it didn’t really work well. The values in ComboBox never remained the selected once after it was sorted. After digging in to the main classes I came up with a solution.

Download source

9 Responses to “FLEX Datagrid header with a ComboBox Filter”


  1. 1 Kode weaver Jun 16th, 2009 at 4:09 pm

    Thanks dude. You saved my time. :)

  2. 2 Harish Jun 17th, 2009 at 9:43 pm

    good work there!

  3. 3 Golnoosh Jun 25th, 2009 at 8:55 pm

    Hi
    I’m impressed with your code! good job! I want to do the exact same thing but I have advancedatagrid instead of datagrid and want to have checkboxes in my combobox and the user is allowed to choose more than one checkbox, so there will be a button in the combobox too. The event will be triggered on the button after the user selects some checkboxes!
    I made this using another code that I found online, but the filtering was not working on the groups! (User is allowed to create summaries and grouping in my UI), so when I apply filter on the groups it shows me emply colums. The filtering is working on the groups with your code though! any suggestions how I can filter using checkboxes, using your code?

    Thanks
    Golnoosh

  4. 4 Omal Raj Jun 25th, 2009 at 10:42 pm

    Hi Golnoosh,

    Update the class com.fb.controls.renderers.LibraryTypesHeaderRenderer to have CheckBoxes in it like you had in your previous code.

    Once the event is dispatched, its caught inside the function “handle_Change” defined in the class com.fb.controls.LibraryTypesHeaderColumn. Update the class com.fb.events.LibraryTypeEvent to hold your filter records and then use the function allDocFilter defined in the class DataGridHeader to filter records based on your choice. Give things a try.

    Happy Coding ;)

  5. 5 kendy Sep 25th, 2009 at 2:57 pm

    Thanks!Good job!

  6. 6 mLindvall Sep 29th, 2009 at 11:56 pm

    Thanks. It works great. All I need now is to figure out how to use create different comboboxs for each header.

    Any thoughts is appreciated.

    Thanks again!!

    Michael Lindvall

  7. 7 kvs Oct 14th, 2009 at 4:33 pm

    is it possible to provide combo box filter and sorting in one column?

  8. 8 DDensa Nov 5th, 2009 at 3:15 pm

    Hello, good work.
    Now i´m trying to do the same thing as mLindvall, i´m trying to use different combobox for each header, and i´m trying to do the same thing as the “MS Excel auto filter function”.. if anyone succeed doing that, please let me know.

    Thank you!

  9. 9 Omal Raj Nov 5th, 2009 at 3:20 pm

    Hi, I will check that one out when I get some time..

    Happy Coding.. :)

Leave a Reply




Calendar

June 2009
M T W T F S S
     
1234567
891011121314
15161718192021
22232425262728
2930  

Categories

Archives