Friday, March 14, 2008

Adding a drop-down button to the OlapDatagrid header

Flex give u the liberty to have different renderers . Well first lets understand how things work ..

  • Place PopUpButton [ PivotPopUpButton] as a headerRenderer for OlapDataGrid
  • When the dropdown is selected the dropdown list provides a list of members of the attribute

OlapDataGrid extends form AdvancedDataGrid.
OlapDataGrid when creating headers , will call makelistdata for each header .
Now if u wish to pass some information apart from already available info u need to create a class that extends AdvancedDataGridListData.

For example in our scenario we need a popUpButton which shows members when a dropdown button is pressed . So the information of members should be passed on to the PopUpButton . So what we do is we create a class PivotListData that extends the AdvancedDataGridListData and add two properties namely
  • hasMembers : Boolean
  • members : ArrayCollection
Now we override makelistData of OlapDataGrid so that it returns PivotListData . So that olapDataGrid gives PivotListData to the renderers . In the renderer's set listdata , you have all the info needed . You can find the source code here

When you click the dropdown button of Company , you can see the choices .( Some problem with popup button coz of which u need to click the button twice ).

[PS : that I havent added the code for filtering here .. Soon I ll post a pivot Component in Flex ]