FLEX 3 Datagrid: How to get column to fit wide text.

I am using the flex3 datagrid with some data where one of the columns is many screens wide. I would like to find a way to make the flex datagrid risize the column to fit the text and to automatically add a left-right scroll bar at the bottom.

Is this possible?
AdrianSmithUKAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
can you post a screen shot?

did you try specifying the <mx:DataGridColumn>  width and height?


did you mean row size? then check this

http://www.flex888.com/712/datagrid-with-flexible-row-height.html
0
AdrianSmithUKAuthor Commented:
Hi Shivaspk

Here is a simple demo.

I am using a 1920px wide monitor and on my screen the text overflows the cell and no scroll bars are added. (See screenshot)

If this was an html table in a browser the page would stretch to the right until it met the end of the text (with the right css of course) and the browser would add a horizontal scroll bar so that the user could navigate to the end of the text.

A simple solution was to set the page to 5000px wide and set the grid to 100% wide. However, I really want the grid to fill the screen (less the padding) and for the table to add scroll bars as necessary.



<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10">

<mx:Script>
	<![CDATA[
	
	[Bindable]
	public var d:String = 'http://cgi.ebay.co.uk/Womens-Rocket-Dog-Preppy-Boat-Shoe_W0QQitemZ130383117582QQcmdZViewItemQQptZWomen_s_Shoes?var=&hash=item641e165555&r=Womens-Rocket-Dog-Preppy-Boat-Shoe_W0QQitemZ130383117582QQcmdZViewItemQQptZWomen_s_Shoes?var=&hash=item641e165555&z=Womens-Rocket-Dog-Preppy-Boat-Shoe_W0QQitemZ130383117582QQcmdZViewItemQQptZWomen_s_Shoes?var=&hash=item641e165555';
		
	]]>
</mx:Script>

<mx:DataGrid width="100%" height="100%" dataProvider="{d}" sortableColumns="true">

<mx:columns>
	<mx:DataGridColumn dataField="d" headerText="Ref" visible="true" />
</mx:columns>

</mx:DataGrid>
	
</mx:Application>

Open in new window

screenshot.jpg
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
Oh I see, just enable the wordWrap on the column and you are done. Try the code attached.
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute" paddingLeft="10" paddingRight="10" paddingTop="10" paddingBottom="10">
	
	<mx:Script>
		<![CDATA[
			
			[Bindable]
			public var d:String = 'http://cgi.ebay.co.uk/Womens-Rocket-Dog-Preppy-Boat-Shoe_W0QQitemZ130383117582QQcmdZViewItemQQptZWomen_s_Shoes?var=&hash=item641e165555&r=Womens-Rocket-Dog-Preppy-Boat-Shoe_W0QQitemZ130383117582QQcmdZViewItemQQptZWomen_s_Shoes?var=&hash=item641e165555&z=Womens-Rocket-Dog-Preppy-Boat-Shoe_W0QQitemZ130383117582QQcmdZViewItemQQptZWomen_s_Shoes?var=&hash=item641e165555';
			
		]]>
	</mx:Script>
	
	<mx:DataGrid width="100%" height="100%" dataProvider="{d}" sortableColumns="true">
		
		<mx:columns>
			<mx:DataGridColumn dataField="d" headerText="Ref" visible="true" wordWrap="true"/>
		</mx:columns>
		
	</mx:DataGrid>
	
</mx:Application>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

AdrianSmithUKAuthor Commented:
Hi Shivaspk

Wordwrap wasn't really what I was looking for, but many thanks for the help.

I really wanted a single row of text and a column that scaled accordingly (like in html). From my invetigations I don't think it's possible without using AS3 and counting characters and setting the chart/column width dynamically.

Do you know of any other method?

0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
scaled accordingly with a scroll bar???
0
AdrianSmithUKAuthor Commented:
Hi Shivaspk

Sorry, I'm not sure I understand your last post.

Could you expand?
0
Siva Prasanna KumarPrincipal Solutions ArchitectCommented:
What I meant was were you expecting to see a scroll bar? as the the row data / column is wider than 100% of the screen visible area.
0
AdrianSmithUKAuthor Commented:
Thank you.

Yes that's right. If I did it in AS3 either the page could scroll or the grid could be made to scroll by adding a scroll bar component at run time. Using the page scroll bars would be easier.

I don't want to waste any more of your time on this issue. I just wondered if you knew of a simple way to achieve the result without resulting to AS3. If not I think we've come to the end of this thread.

Let me know and I'll close the thread down and award the points.

Kind Regards,
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Adobe Flash

From novice to tech pro — start learning today.