views:

36

answers:

1

Hiya. I'm building an application using flex 4.

Using <mx:DataGrid> to display a table.

I would like to add a <s:GlowFilter> to a DataGridColumn.

how can I do so?

thanks!

+1  A: 

You need to create an item renderer with the GlowFilter built in. Here's an example:

My application:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
               xmlns:s="library://ns.adobe.com/flex/spark" 
               xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600">

    <fx:Declarations>
        <s:ArrayCollection id="dataProvider">
            <fx:Object name="Red" color="0xFF0000" />
            <fx:Object name="Green" color="0x00FF00" />
            <fx:Object name="Blue" color="0x0000FF" />
        </s:ArrayCollection>
    </fx:Declarations>

    <mx:DataGrid  itemRenderer="GlowingRenderer" dataProvider="{dataProvider}" />


</s:Application>

...and here's GlowingRenderer.mxml:

<?xml version="1.0" encoding="utf-8"?>
<s:MXDataGridItemRenderer xmlns:fx="http://ns.adobe.com/mxml/2009" 
                          xmlns:s="library://ns.adobe.com/flex/spark" 
                          xmlns:mx="library://ns.adobe.com/flex/mx" 
                          focusEnabled="true" creationComplete="trace(this.data)">

    <fx:Script>
        <![CDATA[
            import spark.filters.GlowFilter;
        ]]>
    </fx:Script>

    <s:Label id="lblData" top="0" left="0" right="0" bottom="0" text="{dataGridListData.label}" filters="{[new GlowFilter(this.data.color)]}" />
</s:MXDataGridItemRenderer>

Doesn't look too pretty, but does the job :)

simon

Simon Gladman
welp i was right.
ufk