stevo84
08-30-2007, 10:49 AM
Hello!
I've been stuck with the following problem for several hours. PLEASE HELP
I am using TutFat custom datagrid in my project. I've to style it reffering to certain conditions. Datagrid contains about 57 lines.
CELL_COLOURING_BY_PARAM = new Array(); //this is the condition for colouring text
CELL_COLOURING_BY_PARAM.push({ColumnName:"Status", CellValue:"solgt"});
CELL_COLOURING_BY_PARAM.push({ColumnName:"Status", CellValue:"reservert"});
for (var color_cell in CELL_COLOURING_BY_PARAM)
{
val = CELL_COLOURING_BY_PARAM[color_cell].CellValue.toLowerCase()
cn = CELL_COLOURING_BY_PARAM[color_cell].ColumnName;
ci = products_dg.getColumnIndex(cn)
var t = new CodeTimer("----Cell colouring time consumption-----");
for (var i:Number=0; i<products_dg.length; i++)
{
if (products_dg.getItemAt(i)[cn].toLowerCase() == val)
products_dg.setCellStyle(i, ci, "textcolor", 0xFF0000);
}
t.trace();
}
Execution times oscilate around 1000ms and rise every time i call this piece of code. Whe i remove the condition in loop, exec times reduce drastically, so I presume that getItemAt() is the bottle neck here. I need help!!! There are a few this kind of loops in my code so sometimes it takes 10s to sort grid (and restyle it afterwards)...
I've been stuck with the following problem for several hours. PLEASE HELP
I am using TutFat custom datagrid in my project. I've to style it reffering to certain conditions. Datagrid contains about 57 lines.
CELL_COLOURING_BY_PARAM = new Array(); //this is the condition for colouring text
CELL_COLOURING_BY_PARAM.push({ColumnName:"Status", CellValue:"solgt"});
CELL_COLOURING_BY_PARAM.push({ColumnName:"Status", CellValue:"reservert"});
for (var color_cell in CELL_COLOURING_BY_PARAM)
{
val = CELL_COLOURING_BY_PARAM[color_cell].CellValue.toLowerCase()
cn = CELL_COLOURING_BY_PARAM[color_cell].ColumnName;
ci = products_dg.getColumnIndex(cn)
var t = new CodeTimer("----Cell colouring time consumption-----");
for (var i:Number=0; i<products_dg.length; i++)
{
if (products_dg.getItemAt(i)[cn].toLowerCase() == val)
products_dg.setCellStyle(i, ci, "textcolor", 0xFF0000);
}
t.trace();
}
Execution times oscilate around 1000ms and rise every time i call this piece of code. Whe i remove the condition in loop, exec times reduce drastically, so I presume that getItemAt() is the bottle neck here. I need help!!! There are a few this kind of loops in my code so sometimes it takes 10s to sort grid (and restyle it afterwards)...