Improve company productivity with a Business Account.Sign Up


Displaying multi-line data in DataGrid using 5000 objects

Posted on 2008-06-26
Medium Priority
Last Modified: 2012-05-05
Sometimes learning too much is a bad thing I think.  In the past, if I needed to create a dataGrid which uses 3 lines of output for each object in my dataprovider, I would just use an item renderer (probably an hbox with vboxes in it or whatever) and add pagination if it were slow.  But since I read chapter 4 in Adobe's "Buildin and Deploying Adobe Flex 3 Applications" I'm hesitant to put containers in containers 4 levels deep, etc.

Essentially, I need to display a report in the dataGrid where each line will always be three lines high.  It needs to resemble a Crystal Report output file that will eventually be generated, but with extra functionality.  So let's say column 1 contains the ID and name of the object.  Column 2 contains the Height on line one, the width on two, and the depth on three.  The real app has 10 columns and a lot more info, but always three lines.

The arrayCollection can have 5000 items in it.  So I figure my options are:
create an item renderer with an HBox containing ten VBoxes as the item renderer and load the sucker up and throw all 5000 items in it, or
do the same item renderer but create pagination or
same item renderer with "continuous scrolling"  (like: which would beg the question, has this been done in reusable form already?

Or else I could do a different item renderer with some other data grabbing method.

My original plan had been to get the objects to the users application instance on an as-needed basis and then keep them there.  But these are fairly large objects and I'm wondering if this is the best idea.  We could end up with an object containing an arrayCollection of about 10 objects, with each of them having 4 arraycollections of objects, with each of those having 5,000 objects... (kind of a state->city->person data model)

And unfortunately since this is geared to be a legacy system replacement, the users are used to being able to see the data continuously without really having to stop/wait or pagination.

Anyway, I hope this all makes sense... I really just need the most efficient, or best practice, method for displaying way too much data in way too small a space.  Easy, right?
Question by:adobe116
LVL 19

Accepted Solution

Gary Benade earned 2000 total points
ID: 21889592
I would do it like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="" layout="absolute" creationComplete="init()">
			import mx.messaging.AbstractConsumer;
			[Bindable] private var d:Array = [];
			private function init():void
				for( var i:int=0; i<5000; i++)
					d.push( {one:'1 ' + i, two:'2 ' + i, three:'3 ' + i, four:'4 ' + i, five:'5 ' + i, six:'6 ' + i, seven:'7 ' + i, eight:'8 ' + i, nine:'9 ' + i, ten:'10 ' + i, eleven:'11 ' + i, twelve:'12 ' + i});		
				dg.dataProvider = d;
	<mx:DataGrid id="dg" x="211" y="162" width="464">
			<mx:DataGridColumn headerText="Column 1" dataField="col1" itemRenderer="BusyItemRenderer"/>
//save as
	import mx.containers.Canvas;
	import mx.controls.Label;
	public class BusyItemRenderer extends Canvas
		private var l1:Label;
		private var l2:Label;
		private var l3:Label;
		private var l4:Label;
		private var l5:Label;
		private var l6:Label;
		private var l7:Label;
		private var l8:Label;
		private var l9:Label;
		private var l10:Label;
		private var l11:Label;
		private var l12:Label;
		public function BusyItemRenderer()
		override public function set data(value:Object):void
		{ = value;
			l1.text =;
			l2.text = data.two;			
			l3.text = data.three;
			l4.text = data.four;			
			l5.text = data.five;
			l6.text = data.six;			
			l7.text =;
			l8.text = data.eight;			
			l9.text = data.nine;
			l10.text = data.ten;			
			l11.text = data.eleven;			
			l12.text = data.twelve;			
		override protected function createChildren():void
			l1 = new Label();
			l1.x = 0;
			l1.y = 0;
			l2 = new Label();
			l2.x = 0;
			l2.y = 10;
			l3 = new Label();
			l3.x = 0;
			l3.y = 20;
			l4 = new Label();
			l4.x = 100;
			l4.y = 0;
			l5 = new Label();
			l5.x = 100;
			l5.y = 10;
			l6 = new Label();
			l6.x = 100;
			l6.y = 20;
			l7 = new Label();
			l7.x = 150;
			l7.y = 0;
			l8 = new Label();
			l8.x = 150;
			l8.y = 10;
			l9 = new Label();
			l9.x = 150;
			l9.y = 20;
			l10 = new Label();
			l10.x = 200;
			l10.y = 0
			l10.setStyle("textAlign", "right");
			l10.setStyle("right", 0);
			l11 = new Label();
			l11.x = 200;
			l11.y = 10
			l11.setStyle("textAlign", "right");
			l11.setStyle("right", 0);
			l12 = new Label();
			l12.x = 200;
			l12.y = 20
			l12.setStyle("textAlign", "right");
			l12.setStyle("right", 0);

Open in new window


Author Closing Comment

ID: 31471046
Hey Hobbit, thanks a lot.  You went above and beyond in answering the question.  Thank you so much.

Featured Post

Become a Leader in Data Analytics

Gain the power to turn raw data into better business decisions and outcomes in your industry. Transform your career future by earning your MS in Data Analytics. WGU’s MSDA program curriculum features IT certifications from Oracle and SAS.  

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

First things first - Preparation We need all the part for this install and it's much nicer to have them all on hand when you need them so here's what's required. Download Eclipse 3.5 32 bit (I like the Classic flavour) from here. (http://www.e…
With the functions here, you can parse, convert, and format back and forth between feet and inches and fractions and decimal inches - for normal as well as extreme values and with extreme precision.
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
From store locators to asset tracking and route optimization, learn how leading companies are using Google Maps APIs throughout the customer journey to increase checkout conversions, boost user engagement, and optimize order fulfillment. Powered …

595 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question