Saturday, June 6, 2009

Showing different icons in each cell of OLAPDataGrid based on the cell value

I have been getting few queries on how to show different icons based on the cell value in a OLAPDataGrid.

Here is a screen shot of how it looks:

Here are the source files.

The technique is simple. Create a custom itemRenderer which can display a icon and text or anything to suite your needs. Make sure it implements the IDropInListItemRenderer interface. In the setter of listData add the logic to change the icon based on the value. Set this as itemRenderer of the OLAPDataGrid.

The sample shows this using a renderer derived from Canvas with a image control and embedded image files. You can use other light weight techniques like coloring a sprite and using UIComponent as base. If you are adventurous you can try tweaking or deriving from OLAPDataGridItemRenderer itself.



Hi Sir,
I want to achieve cell merging vertically in ADG.i have seen the rowSpan and colSpan property in "rendererProvider". i have tried to make a sample for it but it only spans the column but not rows.
So can you please let me know that is it possible with existing properties of ADG or OLAp ADG in flex?

Sreenivas said...

rowSpan is not supported in ADG/ODG. It is a place holder property for future use.

Victor said...

Hi! I read your blog completely and being a flex programmer from the first version i must say yours is one of the best arround.

I wanted to ask you about this: I'm building an application for BI using OLAP queries of course. One of the first things I need is the ability to expand/collapse dimmensions added, not to render all the query but to load on demand. I mean, only load the first dimmension, and when the user clicks one row, expand only that row.

The OLAP grid does not have that function, so I started working with the advanced datagrid and cusotmizing a lot with item renderers (using the expand event to load on demand data from the olap server with xml) .

Do you see any way to achieve that with the OLAP grid or is the ADG way ok for you?
Thank you and the best.

Sreenivas said...

The current ODG doesn't contain this functionality because it was found to be very difficult to maintain the array of cells for expansions across columns and rows.

I think if we can build the back end and client side logic to do incremental query and view updates we can tweak ODG itself to achieve it. I think ODG just uses different renderers to suppress the features it doesn't support.

So my vote goes for tweaking ODG+its renderers to do incremental queries.

roberto said...

I been working with Olap for a BI app as well, after a couple of days and with a lot of help from your posts I got it working with an alternative to drill up/down.

I filter the main data array using a DataModelAdapter before feeding the data to the cube, is not as fancy as the ADG, but it gets the job done.

I have a question, I also want to show a represenative chart, say a column chart. But I am far from figuring out how to use the olap cube as the data provider for a chart. I seen it done in the pivot component example.

Any ideas?

Sreenivas said...

The pivot component example has a OLAPChart. You can use the source of that example and use the OLAPChart outside the pivot component as well. If I remember correctly the OLAPChart takes a IOLAPResult as input.

Sujen said...

Can you please post an example on displaying the "expand--plus" and "collapse--minus" icons on the olapdatagrid column and row headers for the expandable members?


Sreenivas said...

The feature of expanding and collapsing columns/rows is not supported in ODG.


You can change expand(+) and collapse(-) Icon of an item by ADG.setItemIcon() function in ITEM_OPEN event handler.

is it a right way?

Lisa Twede said...

Here's what I'm trying to figure out with OLPADataGrids: All the examples I've seen start with static flat data that is there when the program initializes. So it is fine to run the query as soon as the cube completes. But I need to retrieve data from a database. I think I need to query to run after the data comes from the server. I'd like to see an example like that, because I am having a heck of a time trying to get it to work.

Sreenivas said...

By doing the cube building activity in the result event handler of the service/operation you are using to fetch the data should work.

Tejas said...


I am working on same type of application. But still fighting with creation of OLAPCube schema runtime. Initially load data from Database. After applying some other filters, OLAPDatagrid data should be changed according to that conditions.

Can you please tell us in little-bit detail, how to excetly implement runtime OLAP Datagrid.
Also one more thing, is it possible to set tooltip for Row/Column field name?

Tejas said...


how to build cube at runtime with specific dimensions and attributes and measures.?