Go Back   CodingForums.com > :: Client side development > Flash & ActionScript > Adobe Flex

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 05-19-2011, 07:59 PM   PM User | #1
bon_t
New Coder

 
Join Date: Jul 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
bon_t is an unknown quantity at this point
How to apply formatting on data feeding AdvancedDataGrid

Hello All,

I'm using the Halo AdvancedDataGrid component, in which the default itemEditor for each column is mx.controls.TextInput.

For example, the data provider is:
Code:
[Bindable]
private var labelsGridArray:Array = [ { tag:"apple" }, { tag:"*banana" }, { tag:"carrot" } ];
And the AdvancedDataGrid definition is:
Code:
<mx:AdvancedDataGrid x="115" y="288" id="labelsGrid" designViewDataType="flat" dataProvider="{labelsGridArray}">
If a String from the dataprovider Array is preceded by an asterisk - as is the case for banana in this example - the String needs to be surrounded by square brackets and be displayed in a grey colour.

I tried to do the following:
Code:
<mx:itemRenderer>
	<fx:Component>
		<fx:Script>
			<![CDATA[
			override public function set data(value:Object):void
	ETC.
But this code was never executed. I put breakpoints and they were never accessed, and trace statements that were never written.

A colleague told me about using the AdvancedDataGridColumn's labelFunction attribute. I tried that but was unable to do the following assignment (the id of the column is 'tag'):
Code:
tag.itemEditor.htmlText = formattedText;
I get error "Access of possibly undefined property htmlText through a reference with static type mx.core:IFactory.

I tried to both explicitly extract the TextInput itemEditor (like I did for the override set data) AND use the labelFunction, but I couldn't get both to be in the correct scopes.

Your help is much appreciated,
Bonnie
bon_t is offline   Reply With Quote
Old 05-19-2011, 08:14 PM   PM User | #2
PappaJohn
Senior Coder

 
Join Date: Apr 2007
Location: Quakertown PA USA
Posts: 1,028
Thanks: 1
Thanked 125 Times in 123 Posts
PappaJohn will become famous soon enough
Well, making use of the labelFunction is definitely the way to go. But it's not clear from your post how you are using it.

Please post the mxml code for your data grid and the labelFunction you're written.
__________________
John
PappaJohn is offline   Reply With Quote
Old 05-19-2011, 08:23 PM   PM User | #3
bon_t
New Coder

 
Join Date: Jul 2010
Posts: 32
Thanks: 1
Thanked 0 Times in 0 Posts
bon_t is an unknown quantity at this point
Hi John,

Thanks for your quick reply. As requested, here is my AdvancedDataGrid definition in whole. I've not written the code yet for the labelFunction because I'm still having trouble putting everything in the proper scopes.

Code:
<mx:AdvancedDataGrid x="115" y="288" id="labelsGrid" designViewDataType="flat" dataProvider="{labelsGridArray}">
	<mx:columns>
		<mx:AdvancedDataGridColumn id="tag" headerText="Tag" dataField="tag" width="90" labelFunction="tag_labelFunction">
			<mx:itemEditor>
				<fx:Component>
					<mx:HBox>
						<mx:TextInput id="ti"/>
					</mx:HBox>
				</fx:Component>
			</mx:itemEditor>
		</mx:AdvancedDataGridColumn>
		<fx:Script> 
			<![CDATA[
				import mx.controls.advancedDataGridClasses.AdvancedDataGridColumn;
					
				protected function tag_labelFunction( item:Object, column:AdvancedDataGridColumn ):void
				{
					var formattedText:String = "";
						
					tag.ti.htmlText = formattedText;
				}
			]]>
		</fx:Script>		
	</mx:columns>
</mx:AdvancedDataGrid>
The statement
tag.ti.htmlText = formattedText;
generates the following error:
Access of possibly undefined property ti through a reference with static type mx.controls.advancedDataGridClasses.AdvancedDataGridColumn

I've tried moving the function definition within the Hbox, but then the AdvancedDataGridColumn can't access it.

Help!
Bonnie
bon_t is offline   Reply With Quote
Reply

Bookmarks

Tags
htmltext formatting

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 12:53 AM.


Advertisement
Log in to turn off these ads.