Set DataGrid headerRenderer dynamically

View: New views
2 Messages — Rating Filter:   Alert me  

Set DataGrid headerRenderer dynamically

by Brian McCairn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Hi

Flex newbie so be gentle.

I've got a function to create a new colummn in a grid ...

             private function addBlankDataGridColumn(dataField:String):void
            {
                var dgc:DataGridColumn = new DataGridColumn(dataField);
                dgc.headerText="hi2";
                dgc.headerRenderer="VDGHeader";
                var cols:Array = musicDatagrid.columns;
                cols.push(dgc);
                musicDatagrid.columns = cols;
            }

This works fine apart from the line

dgc.headerRenderer="VDGHeader";

I can set the headerRenderer="VDGHeader" as a parameter in predefined columns and it works fine, but in the function above it causes the following error

1067: Implicit coercion of a value of type String to an unrelated type mx.core:IFactory.

I've tried

dgc.setHeaderRenderer("VDGHeader");

but no luck.

Can you set the headerRenderer dynamically?

Thanks

Brian


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5880
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37

Re: Set DataGrid headerRenderer dynamically

by Brian McCairn :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


> Hi
>
> Flex newbie so be gentle.
>
> I've got a function to create a new colummn in a grid ...
>
             
> private function addBlankDataGridColumn(dataField:String):void
           
> {
               
> var dgc:DataGridColumn = new DataGridColumn(dataField);
               
> dgc.headerText="hi2";
               
> dgc.headerRenderer="VDGHeader";
               
> var cols:Array = musicDatagrid.columns;
               
> cols.push(dgc);
               
> musicDatagrid.columns = cols;
           

> }
>
> This works fine apart from the line
>
> dgc.headerRenderer="VDGHeader";
>
> I can set the headerRenderer="VDGHeader" as a parameter in predefined
> columns and it works fine, but in the function above it causes the
> following error
>
> 1067: Implicit coercion of a value of type String to an unrelated type
> mx.core:IFactory.
>
> I've tried
>
> dgc.setHeaderRenderer("VDGHeader");
>
> but no luck.
>
> Can you set the headerRenderer dynamically?
>
> Thanks
>
> Brian


I found the following seems to do the trick

dgc.headerRenderer= new ClassFactory(VDGHeader);

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Want to reach the ColdFusion community with something they want? Let them know on the House of Fusion mailing lists
Archive: http://www.houseoffusion.com/groups/flex/message.cfm/messageid:5897
Subscription: http://www.houseoffusion.com/groups/flex/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=17837.14401.37