Discussion:
Datagrid initialization very slow?
(too old to reply)
Rajat K. Paharia
2005-06-02 06:01:00 UTC
Permalink
When my app starts up I have a function that
initializes all the grids that I use in my app. There
are 6 grids, with a total of 26 columns between them
being initialized with code like this:

col = new DataGridColumn("icon");
col.headerText = "";
col.width = 25;
col.cellRenderer = "IconCellRenderer";
grid.addColumn(col);

Running this code takes a loooooong time. When I
comment this code out, on a fast machine my app takes
1-2 seconds to start. When I leave it in, my app takes
6-7 seconds to start. I tested my app on an older
machine (Win2k, P3-450, 320MB RAM) and it took so
long, I even got the dreaded "Script running slowly"
error, which shocked me.

Is there some more efficient way to setup grids? Or do
I need to make the initialization of each grid "on
demand" to spread the delay around, rather than
iniitalizing them all at once at application startup?

Any ideas would be appreciated. best, - rajat



__________________________________
Discover Yahoo!
Stay in touch with email, IM, photo sharing and more. Check it out!
http://discover.yahoo.com/stayintouch.html
hank williams
2005-06-02 12:04:58 UTC
Permalink
Yes, grid initialization is *painfully* slow.

I do believe that the right strategy is initialization on demand
because doing lots of grids upfront is unacceptable from a performance
perspective.

Regards
Hank
Post by Rajat K. Paharia
When my app starts up I have a function that
initializes all the grids that I use in my app. There
are 6 grids, with a total of 26 columns between them
col = new DataGridColumn("icon");
col.headerText = "";
col.width = 25;
col.cellRenderer = "IconCellRenderer";
grid.addColumn(col);
Running this code takes a loooooong time. When I
comment this code out, on a fast machine my app takes
1-2 seconds to start. When I leave it in, my app takes
6-7 seconds to start. I tested my app on an older
machine (Win2k, P3-450, 320MB RAM) and it took so
long, I even got the dreaded "Script running slowly"
error, which shocked me.
Is there some more efficient way to setup grids? Or do
I need to make the initialization of each grid "on
demand" to spread the delay around, rather than
iniitalizing them all at once at application startup?
Any ideas would be appreciated. best, - rajat
__________________________________
Discover Yahoo!
Stay in touch with email, IM, photo sharing and more. Check it out!
http://discover.yahoo.com/stayintouch.html
_______________________________________________
Flashcoders mailing list
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Bianca Cicos
2005-06-08 08:15:52 UTC
Permalink
I have this class "DoubleClickDataGrid"; and I want to add the doubleClick
to it.
I have the code that works alone, but I don't know how to rewrite it for
this class.



//___________________________________________________
import mx.controls.DataGrid;
import mx.core.UIComponent;


dynamic class DoubleClickDataGrid extends UIComponent{

private var container_mc:MovieClip;

// we declare our Bounding Box here so that we can
// reference it in our code
private var boundingBox_mc:MovieClip;


function DoubleClickDataGrid() {
trace('constructor DoubleClickDataGrid');
}

private function init():Void {
trace('init');

super.init();

boundingBox_mc._visible = false;
boundingBox_mc._width = boundingBox_mc._height = 0;

if (container_mc == undefined) {
container_mc = this.attachMovie("container_mc","container_mc",10);
//getNextDepth());
//container_mc._visible = false;
}
}

function setInitialState(){
var gridDP:Array = new Array({FirstName:"White",LastName:"Joe"},
{FirstName:"Brain",LastName:"Adam"});
//assign the array to the grid's dataProvider
container_mc.grid_dg.dataProvider = gridDP;
trace(container_mc.grid_dg);
}
function addDoubleClick(){
.............
}
}



Here is the code that works alone.


//_____________________________________________________
/*
mx.controls.DataGrid.prototype.addDoubleClick = function() {
this.addProperty("onDoubleClick",
function () { return this.$onDoubleClick;},
function (func) {
this.$onDoubleClick = func;
this.$reset = function() {
clearInterval(this.id <http://this.id>);
this.firstClick = false;
};
this.onPress = function() {
if (this.firstClick) {
this.$onDoubleClick();
this.$reset();
} else {
this.firstClick = true;
this.onSingleClick();
this.id <http://this.id> = setInterval(this, "$reset", 500);
}
};
}
);
}

dg.addDoubleClick();

dg.onDoubleClick = function() {
trace("double click detected!");
};

dg.onSingleClick = function() {
trace("click detected!");
};

PS: Now I extend UIComponent. This is a good idee or should I extends the
DataGrid?

Thanks,
Bianca
Post by hank williams
Yes, grid initialization is *painfully* slow.
I do believe that the right strategy is initialization on demand
because doing lots of grids upfront is unacceptable from a performance
perspective.
Regards
Hank
Post by Rajat K. Paharia
When my app starts up I have a function that
initializes all the grids that I use in my app. There
are 6 grids, with a total of 26 columns between them
col = new DataGridColumn("icon");
col.headerText = "";
col.width = 25;
col.cellRenderer = "IconCellRenderer";
grid.addColumn(col);
Running this code takes a loooooong time. When I
comment this code out, on a fast machine my app takes
1-2 seconds to start. When I leave it in, my app takes
6-7 seconds to start. I tested my app on an older
machine (Win2k, P3-450, 320MB RAM) and it took so
long, I even got the dreaded "Script running slowly"
error, which shocked me.
Is there some more efficient way to setup grids? Or do
I need to make the initialization of each grid "on
demand" to spread the delay around, rather than
iniitalizing them all at once at application startup?
Any ideas would be appreciated. best, - rajat
__________________________________
Discover Yahoo!
Stay in touch with email, IM, photo sharing and more. Check it out!
http://discover.yahoo.com/stayintouch.html
_______________________________________________
Flashcoders mailing list
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Bart Wttewaall
2005-06-11 11:43:34 UTC
Permalink
Hi Bianca,

This reply may come a bit late, but I'm still trying to catch up on last
weeks posts :P
Your question might already have been answered, but here's my solution:

Inbox_dg.addEventListener("cellPress", mx.utils.Delegate.create(this,
cellPress));

public function cellPress(evt) {
if (getTimer()-lastClick < 300) onDoubleClick(evt);
lastClick = getTimer();
}

public function onDoubleClick(evt) {
openRow(evt.target);
}

good luck!
Bart Wttewaall
Subject: [Flashcoders] class DoubleClickDataGrid
Date: Wed, 8 Jun 2005 11:15:52 +0300
I have this class "DoubleClickDataGrid"; and I want to add the doubleClick
to it.
I have the code that works alone, but I don't know how to rewrite it for
this class.
//___________________________________________________
import mx.controls.DataGrid;
import mx.core.UIComponent;
dynamic class DoubleClickDataGrid extends UIComponent{
private var container_mc:MovieClip;
// we declare our Bounding Box here so that we can
// reference it in our code
private var boundingBox_mc:MovieClip;
function DoubleClickDataGrid() {
trace('constructor DoubleClickDataGrid');
}
private function init():Void {
trace('init');
super.init();
boundingBox_mc._visible = false;
boundingBox_mc._width = boundingBox_mc._height = 0;
if (container_mc == undefined) {
container_mc = this.attachMovie("container_mc","container_mc",10);
//getNextDepth());
//container_mc._visible = false;
}
}
function setInitialState(){
var gridDP:Array = new Array({FirstName:"White",LastName:"Joe"},
{FirstName:"Brain",LastName:"Adam"});
//assign the array to the grid's dataProvider
container_mc.grid_dg.dataProvider = gridDP;
trace(container_mc.grid_dg);
}
function addDoubleClick(){
.............
}
}
Here is the code that works alone.
//_____________________________________________________
/*
mx.controls.DataGrid.prototype.addDoubleClick = function() {
this.addProperty("onDoubleClick",
function () { return this.$onDoubleClick;},
function (func) {
this.$onDoubleClick = func;
this.$reset = function() {
clearInterval(this.id <http://this.id>);
this.firstClick = false;
};
this.onPress = function() {
if (this.firstClick) {
this.$onDoubleClick();
this.$reset();
} else {
this.firstClick = true;
this.onSingleClick();
this.id <http://this.id> = setInterval(this, "$reset", 500);
}
};
}
);
}
dg.addDoubleClick();
dg.onDoubleClick = function() {
trace("double click detected!");
};
dg.onSingleClick = function() {
trace("click detected!");
};
PS: Now I extend UIComponent. This is a good idee or should I extends the
DataGrid?
Thanks,
Bianca
Post by hank williams
Yes, grid initialization is *painfully* slow.
I do believe that the right strategy is initialization on demand
because doing lots of grids upfront is unacceptable from a performance
perspective.
Regards
Hank
Post by Rajat K. Paharia
When my app starts up I have a function that
initializes all the grids that I use in my app. There
are 6 grids, with a total of 26 columns between them
col = new DataGridColumn("icon");
col.headerText = "";
col.width = 25;
col.cellRenderer = "IconCellRenderer";
grid.addColumn(col);
Running this code takes a loooooong time. When I
comment this code out, on a fast machine my app takes
1-2 seconds to start. When I leave it in, my app takes
6-7 seconds to start. I tested my app on an older
machine (Win2k, P3-450, 320MB RAM) and it took so
long, I even got the dreaded "Script running slowly"
error, which shocked me.
Is there some more efficient way to setup grids? Or do
I need to make the initialization of each grid "on
demand" to spread the delay around, rather than
iniitalizing them all at once at application startup?
Any ideas would be appreciated. best, - rajat
__________________________________
Discover Yahoo!
Stay in touch with email, IM, photo sharing and more. Check it out!
http://discover.yahoo.com/stayintouch.html
_______________________________________________
Flashcoders mailing list
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
_______________________________________________
Flashcoders mailing list
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Continue reading on narkive:
Search results for 'Datagrid initialization very slow?' (Questions and Answers)
5
replies
can i get question answer of asp.net ?
started 2006-10-11 00:02:47 UTC
software
Loading...