Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Flex > Flex 2, 3 & 4

Reply
 
Thread Tools Rate Thread Display Modes
Old 06-17-2008, 08:20 PM   #1
wGrand
Member
 
Join Date: Feb 2007
Location: Boston
Posts: 43
Default List Component - rowCount defaults to 7; auto size?

The <mx:List> component defaults to 7 rows.

I was able to make it readjust by initiating this code on creationComplete():
ActionScript Code:
if(this.collection.length<6)                     this.rowCount=this.collection.length;                 else                     this.rowCount=5;

But, I drag items in and out of the list and the rowCount doesn't update. Neither does its width. Is there a way to make it automatically size?
wGrand is offline   Reply With Quote
Old 06-17-2008, 09:24 PM   #2
ryang
Registered User
 
Join Date: Jun 2008
Posts: 7
Default Bind the Row Count to the Length of the Collection

Are you using mxml to call the list? Try...

Code:
<mx:List dataProvider="{collection}" 
        rowCount="{Math.min(collection.length, 5)}" />
ryang is offline   Reply With Quote
Old 06-18-2008, 04:17 AM   #3
wGrand
Member
 
Join Date: Feb 2007
Location: Boston
Posts: 43
Default

Wow! Very smart. I get a warning saying that it may not be able to bind to 'collection' though
wGrand is offline   Reply With Quote
Old 06-18-2008, 05:46 AM   #4
ryang
Registered User
 
Join Date: Jun 2008
Posts: 7
Default

make sure to make collection "bindable" where you declare it.

for example....
ActionScript Code:
[Bindable] public var collection:ArrayCollection = new ArrayCollection();

if you are filling your collection from a remote object or webservice call, and your result is an Array, then make sure to set the "source" property, not the collection itself, or you will break the binding.

eg.
ActionScript Code:
public function result(data:Object):void {   collection.source = data.result as Array; }

if you are filling it manually, then use the "addItem" method to add items to your collection.

HTH,
Ryan
ryang is offline   Reply With Quote
Reply


Thread Tools
Display Modes 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

Similar Threads
Thread Thread Starter Forum Replies Last Post
list box component not inserting data somnamblst Components 16 09-10-2007 02:01 PM
dragDrop, Tile List to List Component LostInRecursion Flex 2, 3 & 4 0 07-20-2006 01:38 AM
Scope Problem with List Component Inside Accordion Scottiedazzle ActionScript 2.0 1 07-18-2006 03:51 PM
List Component sleepydad Components 4 03-09-2006 02:51 AM
list component auto select Vivianne Components 5 10-07-2004 11:13 PM


All times are GMT. The time now is 04:34 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.