• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 847
  • Last Modified:

Displaying multi-line data in DataGrid using 5000 objects

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: http://ui-patterns.com/pattern/ContinuousScrolling) 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?
1 Solution
Gary BenadeCommented:
I would do it like this:
<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" 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 BusyItemRenderer.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
			super.data = value;
			l1.text = data.one;
			l2.text = data.two;			
			l3.text = data.three;
			l4.text = data.four;			
			l5.text = data.five;
			l6.text = data.six;			
			l7.text = data.seven;
			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

adobe116Author Commented:
Hey Hobbit, thanks a lot.  You went above and beyond in answering the question.  Thank you so much.
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

Featured Post

Become an IT Security Management Expert

In today’s fast-paced, digitally transformed world of business, the need to protect network data and ensure cloud privacy has never been greater. With a B.S. in Network Operations and Security, you can get the credentials it takes to become an IT security management expert.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now