:: Forum >>

Grid - Performance - too slow.

Dear Alex,
I am using demoversion to check whether it suits our site or not.
I m facing some problems, please help me to sort it out.

I used virtual mode - false. but still page rendering is very slow. it taking 5 to 10 mins to display the data of 700 rows and 10 columns, having one column with HyperLink.

more over IE showing following warning message___

"A script on this page is causing Internet Explorer to run slowly, if it continues to run your computer may become unresponsive.

Do you want to abort the script?
Yes No
"
MY PC Cong.
Intel P4 2.00 GHz
256 MB RAM.

CPU Usages: 100%
PF Usages: 507 MB
for 3 mins.

Please Help me regarding this performance issue.
Ashish Dhanorkar [Ashida001@gmail.com]
Friday, February 15, 2008
Ashish,

I'm a different Alex from the one you are addressing, but I'm guessing I may have a clue as to why the grid is slow. Virtual mode needs to be turned on for grid to be faster, so you set it to true not false.
Alex Ndungu
Friday, February 15, 2008
>> I used virtual mode - false.

You should keep virtual mode = true for the large datasets. Switching off virtual mode is only suitable for the small grids (less than 100 rows).
Alex (ActiveWidgets)
Friday, February 15, 2008
Hey ALEX,

THANKS BOTH OF U....
BUT STILL I M FACING SAME PROBLEM... EVEN AFTER ALTERING THE VERTUAL MODE BETWEEN "TRUE" AND "FALSE".....

STILL IT TAKING SAME TINE [~2 MINS] TO LOAD DATA IN GRID...

IF U CAN SPARE SOME TIME AND TRY MY CASE, U MAY FOUND MY MISTAKE WHICH CAUSING THIS PROBLEM

u can try the explample taking 700 rows and 9 cols and following data...

>> Code goes here <<

<span id="grid1"></span>

>> Break <<

>> Javascript Code <<

function onpenNewWinCompIPO(cLink,cTitle)
{
window.open(cLink,cTitle,'scrollbars=yes,resizable=yes,top=150,left=150,width=430,height=320')
}

var grRowNum;
grRowNum = 0;
var grid1 = new AW.UI.Grid;
grid1.setId("grid1");
grid1.setColumnCount(9);
grid1.setHeaderText("Date", 0);
grid1.setHeaderText("Reference No", 1);
grid1.setHeaderText("Exch.", 2);
grid1.setHeaderText("Bank", 3);
grid1.setHeaderText("Cheque", 4);
grid1.setHeaderText("Description", 5);
grid1.setHeaderText("Debit", 6);
grid1.setHeaderText("Credit", 7);
grid1.setHeaderText("Balance", 8);
//grid1.setCellText("Cell");
grid1.setHeaderHeight(20); // header height - 40px


>> Code Break <<

>> Code: Continue <<
grid1.addRow(grRowNum);
grRowNum++;
grid1.setCellData("04/04/2007",0,grRowNum);
grid1.setCellData("DR/003/---92 ",1,grRowNum);
grid1.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,grRowNum);
grid1.setCellTemplate(new AW.Templates.Link,1,grRowNum);
grid1.setCellData(" ",2,grRowNum);
grid1.setCellData(" ",3,grRowNum);
grid1.setCellData("By Bill DR/003/---92 for Ex: BSE,- BT: DEPOSITORY - Settlement=2007003,,",4,grRowNum);
grid1.setCellData("",6,grRowNum);
grid1.setCellData("1,590,957.99",7,grRowNum);
grid1.setCellData("2,871,224.47&nbsp;Cr",8,grRowNum);


>> break <<

like this 700 rows having one cell a link opning a popup.

and at last some more code .....

>> Code: Continue <<

grid1.setVirtualMode(false);
//grid1.clearSortModel();
//grid1.onHeaderClicked = function(){return true};
//grid1.getHeaderTemplate().refresh();
grid1.refresh();
//object.write(grid1);

>> end <<


NOW IF U CAN TRY THIS U CAN FIND IT TAKING TIME.... PLEASE SUGGEST ME IF U CAN TRACK OUT THE PROLEM......

THAKNS ONCE AGAIN RESPONDING ME.....
Ashish Dhanorkar [Ashida001@gmail.com]
Wednesday, February 20, 2008
i m sorry alex,

please try this code at last....

>> Code: Continue <<

grid1.setVirtualMode(true);
//grid1.clearSortModel();
//grid1.onHeaderClicked = function(){return true};
//grid1.getHeaderTemplate().refresh();
grid1.refresh();
//object.write(grid1);

>> end <<

thanks

Ashish Dhanorkar [Ashida001@gmail.com]
Wednesday, February 20, 2008
Ashish,

Does your application structure allow you to load the data as a javascript array as illustrated by:

http://www.activewidgets.com/grid.examples/asp-adodb.html

I think it could be faster since it runs on the server and sends the completed data to the browser for processing by AW.
Alex Ndungu
Wednesday, February 20, 2008
Thanks Alex,

as u said I tried with the arrays, its really incredibly fast.
but as I need
OnClick - some PopUp should open
or applying different styles to columns as per need of data
or changing font color in individual CELL as per data; like credit amount should appear in GREEN and debit amount should appear RED...

such Cell Level scripting i not able to perform with arrays...

in previous code i used OnClick on 2nd column.

but now code which i m giving is like what u said in ur replay...


>>>>> Code Start <<<<<

'''''''' ASP Code ''''''''''

dim grRowNum
grRowNum = 0

dim vScript, noOfRows
vScript = ""
noOfRows = rsq.recordcount

vScript = vScript & "[" & vbCrLf
while rsq.EOF=false

dim xyz,v
xyz=rsq(5)
if xyz="5" then
v="Bill"
end if
if xyz="4" then
v="Payment"
end if
if xyz="3" then
v="Receipt"
end if
if xyz="2" then
v="JournalVoucher"
end if
if xyz="1" then
v="OpenEntry"
end if

''' Comment - creating varialble for array

if(rsq(0)) ="0" then
vScript = vScript & "['',"
else
vScript = vScript & "['" & convertdateddmmyyyy(rsq(0)) & "',"
end if

if xyz="5" then
vScript = vScript & "'" & Trim(rsq(1)) & "',"
else
vScript = vScript & "'" & Trim(rsq(1)) & "',"
end if

if(rsq(2)) ="0" then
vScript = vScript & "'',"
else
vScript = vScript & "'" & Trim(rsq(2)) & "',"
end if

if(rsq(3)) ="0" then
vScript = vScript & "'',"
else
vScript = vScript & "'" & Trim(rsq(3)) & "',"
end if

if(rsq(4)) ="0" then
vScript = vScript & "'',"
else
vScript = vScript & "'" & Trim(rsq(4)) & "',"
end if

if(rsq(6)) = "0" then
vScript = vScript & "'',"
else
vScript = vScript & "'" & formatnumber(rsq(6),2) & "',"
end if

if(rsq(7)) = "0" then
vScript = vScript & "'',"
else
vScript = vScript & "'" & formatnumber(rsq(7),2) & "',"
end if

db=cdbl(rsq(6))
cr=cdbl(rsq(7))
if x<>"" then
end if
bal = (db-cr)+runbal

if bal > 0 then
color = "red"
bal_val = formatnumber(round((abs(bal)),2),2) & "&nbsp;Dr"
else
color = "green"
bal_val = formatnumber(round((abs(bal)),2),2) & "&nbsp;Cr"
end if

vScript = vScript & "'" & bal_val & "']"

grRowNum = grRowNum + 1
runbal = bal
rsq.MoveNext
if not rsq.eof then
vScript = vScript & "," & vbCrLf
end if
wend
vScript = vScript & "];"

'''''''''''''' ASP Code End ''''''''''''''
%>

<script language=JavaScript>

var arrData = <%=vScript%>

function onpenNewWinCompIPO(cLink,cTitle)
{
window.open(cLink,cTitle,'scrollbars=yes,resizable=yes,top=150,left=150,width=430,height=320')
}

var grid1 = new AW.UI.Grid;
grid1.setId("grid1");
grid1.setColumnCount(9);
grid1.setRowCount(<%=noOfRows%>);
grid1.setHeaderText("Date", 0);
grid1.setHeaderText("Reference No", 1);
grid1.setHeaderText("Exch.", 2);
grid1.setHeaderText("Bank", 3);
grid1.setHeaderText("Cheque", 4);
grid1.setHeaderText("Description", 5);
grid1.setHeaderText("Debit", 6);
grid1.setHeaderText("Credit", 7);
grid1.setHeaderText("Balance", 8);
grid1.setHeaderHeight(20); // header height - 40px

grid1.setCellText(arrData);
grid1.setVirtualMode(true);
grid1.refresh();
</script>

>>>>>>>>>> Code End Here<<<<<<<<<<<<<<

So, I think I need to assign data to individual Cell, is only way... which make the grid to perform slow...

Warm Regards,
Ashish....
Ashish Dhanorkar [Ashida001@gmail.com]
Thursday, February 21, 2008
Ashsish,

Try this and see whether it works any faster:

<%
Dim rowCount
Dim rowData
Dim cellStyle
Dim cellUrl
quote = chr(34)
rowCount = 0
Do Until rsq.EOF
'row ID
rowData = rowData & "myData[" & quote & rsq.Fields("Date") & quote & "] = "
'row data
rowData = rowData & "["
rowData = rowData & quote & rsq.Fields("Date") & quote & ","
rowData = rowData & quote & rsq.Fields("Reference") & quote & ","
cellUrl = cellUrl & "grid1.setCellLink(""javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')"",1," & rowCount & ");" & vbCrLf
rowData = rowData & quote & rsq.Fields("Exch") & quote & ","
rowData = rowData & quote & rsq.Fields("Bank") & quote & ","
rowData = rowData & quote & rsq.Fields("Cheque") & quote & ","
rowData = rowData & quote & rsq.Fields("Description") & quote & ","
rowData = rowData & quote & rsq.Fields("Debit") & quote & ","
rowData = rowData & quote & rsq.Fields("Credit") & quote & ","
rowData = rowData & quote & rsq.Fields("Balance") & quote
If rsq.Fields("Balance") < 0 Then
cellStyle = cellStyle & "#grid1 .aw-row-" & rowCount & " .aw-column-8 {color: red;}" & vbCrLf
Else
cellStyle = cellStyle & "#grid1 .aw-row-" & rowCount & " .aw-column-8 {color: green;}" & vbCrLf
End If
rowData = rowData & "];" & vbCrLf
'build the row IDs array
rowIDs = rowIDs & quote & rsq.Fields("Date") & quote
rowCount = rowCount + 1
rsq.MoveNext
if not(rsq.eof) then
intRecord = intRecord + 1
rowIDs = rowIDs & ","
end if
Loop
%>
<style>
<%= cellStyle %>
</style>
<script language="javascript">
var rowCount = <%= rowCount %>;
var colCount = 9;
var myColumns = ["Date", "Reference No", "Exch", "Bank", "Cheque", "Description", "Debit", "Credit", "Balance"];
var myRowIDs = [<%=rowIDs%>];
var myData = [];
<%=rowData%>

// create ActiveUI Grid javascript object
var grid = new AW.UI.Grid;
grid.setId("grid1");
// provide cells and headers text
grid.setCellText(myData);
grid.setHeaderText(myColumns);
// set rows ids
grid.setRowIndices(myRowIDs);
// set number of columns and rows
grid.setColumnCount(colCount);
grid.setRowCount(rowCount);

//load the URLs
<%= cellUrl %>

//set the URL template for column 1
grid1.setCellTemplate(new AW.Templates.Link,1);

// write grid html to the page
document.write(grid);

</script>
Alex Ndungu
Thursday, February 21, 2008
correction:

1) change

grid1.setCellTemplate(new AW.Templates.Link,1);

to

grid.setCellTemplate(new AW.Templates.Link,1);

2) change

cellUrl = cellUrl & "grid1.setCellLink(""javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')"",1," & rowCount & ");" & vbCrLf

to

cellUrl = cellUrl & "grid.setCellLink(""javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')"",1," & rowCount & ");" & vbCrLf
Alex Ndungu
Thursday, February 21, 2008
THANKS ALEX,

THIS WAS REALY IMPRESSIVE SCRIPT, I GOT REALY GREATE IDEAS TO PLAY WITH THE GRID.

BUT STILL PROBLE IS: ON CLINKING ON CELL WITH LINK IT DOING NOTHING.

I M GIVING U """ HTML CODE """ TO TEST.

PLEASE REFFER ME CHECKING IN UR CODE GIVEN BEFORE.

>>>>> HERE IS HTML CODE <<<<<<<<



<HTML>
<HEAD>
<title>Financial Details</title>


<link rel="stylesheet" href="mp2000css.css">
<SCRIPT LANGUAGE=javascript src="calendar.js"></SCRIPT>
<style>
#grid {height: 350px}
#grid {width: 100% }
#grid {border: solid 1px red}
#grid {text-align: left}
#grid .aw-column-1 {width: 100px}
//#grid1 .aw-column-0 {background-color:yellow}
#grid .aw-column-3 {text-align: center}

</style>



</HEAD>
<script src="ActiveWidgets280108/runtime/lib/aw.js"></script>
<link href="ActiveWidgets280108/runtime/styles/system/aw.css" rel="stylesheet"></link>
<link rel="stylesheet" href="mp2000css.css">
<BODY leftmargin=0 topmargin=0 rightmargin=0 bottommargin=0 marginwidth=0>

<script language=JavaScript>
function onpenNewWinCompIPO(cLink,cTitle)
{
window.open(cLink,cTitle,'scrollbars=yes,resizable=yes,top=150,left=150,width=430,height=320')
}
</script>



<!--span id="grid1"></span-->

<style>
#grid.aw-row-0 .aw-column-8 {color: green;}
#grid.aw-row-1 .aw-column-8 {color: red;}
#grid.aw-row-2 .aw-column-8 {color: green;}
#grid.aw-row-3 .aw-column-8 {color: red;}
#grid.aw-row-4 .aw-column-8 {color: red;}
#grid.aw-row-5 .aw-column-8 {color: green;}
#grid.aw-row-6 .aw-column-8 {color: red;}
#grid.aw-row-7 .aw-column-8 {color: green;}

</style>
<script language="javascript">

var rowCount = 8;
var colCount = 9;
var myColumns = ["Date", "Reference No", "Exch", "Bank", "Cheque", "Description", "Debit", "Credit", "Balance"];
var myRowIDs = ["4/1/2007","4/26/2007","5/10/2007","6/22/2007","7/3/2007","7/14/2007","12/5/2007","2/20/2008"];
var myData = [];
myData["4/1/2007"] = ["4/1/2007","OPNGRTBSE 0 "," "," ","BY OPENING BALANCE B/F,,,","1","0","6632.06","BSE "];
myData["4/26/2007"] = ["4/26/2007","PYIBAPR0000311","ICCLTCASHB","*TFR ","YOUR A/C. HAS BEEN DEBITED TOWARDS :,ON A/C,Cr to ICICI BANK A/c No. 000401013509,25/04/2007-2","4","6000","0","BSE "];
myData["5/10/2007"] = ["5/10/2007","DR/026/---20 "," "," ","By Bill DR/026/---20 for Ex: BSE,- BT: DEPOSITORY - Settlement=2007026,,","5","0","48469.6","BSE "];
myData["6/22/2007"] = ["6/22/2007","PYIBJUN0000361","ICCLTCASHB","*TFR ","YOUR A/C. HAS BEEN DEBITED TOWARDS :,ON A/C,Cr to ICICI BANK A/c No. 000401013509,21/06/2007-2","4","49101.66","0","BSE "];
myData["7/3/2007"] = ["7/3/2007","JVJUL_C0001652"," "," ","Tr DP Dr of BO#024454 to 1750,,,","2","347.95","0","BSE "];
myData["7/14/2007"] = ["7/14/2007","REIC07B0001115"," "," ","CHQ-0493389-13/07/2007,I.C.I.C.I. BANKING CORPORATION LTD.-NARIMAN P,RT-17609-8311,","3","0","348","BSE "];
myData["12/5/2007"] = ["12/5/2007","JVDEC_C0003352"," "," ","Trf Dp Dr - Bo#024454 To 1750 ","2","28.09","0","BSE "];
myData["2/20/2008"] = ["2/20/2008","REIC02B0003000"," "," ","Nt-0000000-20/02/2008 I.c.i.c.i. Banking Corporation Ltd.-nt Rt-58800-58800 ","3","0","30","BSE "];


// create ActiveUI Grid javascript object
var grid = new AW.UI.Grid;
grid.setId("grid");
// provide cells and headers text
grid.setCellText(myData);
grid.setHeaderText(myColumns);
// set rows ids
grid.setRowIndices(myRowIDs);
// set number of columns and rows
grid.setColumnCount(colCount);
grid.setRowCount(rowCount);

//load the URLs
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,0);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,1);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,2);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,3);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,4);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,5);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,6);
grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,7);


//set the URL template for column 1
grid.setCellTemplate(new AW.Templates.Link,1);

// write grid html to the page
document.write(grid);
//grid1.refresh();

</script>

</BODY>
</HTML>


>>>>>>>>> CODE ENDS HERE <<<<<<<<<<<<<

PLEASE FIND BUG IN MY CODE AND LET ME KNOW....

WARM REGARDS,
ASHISH DHANORKAR.
Ashish Dhanorkar [Ashida001@gmail.com]
Friday, February 22, 2008
Ashish,

The problem seems to be with the row ids. This line:

grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,0);

attempts to assign the url to the first row by calling it row 0. This is the bug since the row is called "4/1/2007" as indicated by the myRowIDs array. This means that the cell link should be assigned with the following kind of reference:

grid.setCellLink("javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')",1,"4/1/2007");

In order to produce this kind of code, the ASP code I sent earlier needs to be modified such that the line:

cellUrl = cellUrl & "grid.setCellLink(""javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')"",1," & rowCount & ");" & vbCrLf

changes to:

cellUrl = cellUrl & "grid.setCellLink(""javascript:onpenNewWinCompIPO('bill.asp?title=Bill%20Details&e=ALL&b=2007003&v=BSE &cc=60366 &brc=RT &r=DR/003/---92 &d=4/4/2007&da=0&cam=1590957.99&cn=VIRESH P SHAH ','Comp')"",1," & quote & rsq.Fields("Date") & quote & ");" & vbCrLf

Alex Ndungu
Friday, February 22, 2008
HEY ALEX,

THANKS FOR THIS GREATE SUGGESSION. ITS WORKING. THIS WAS REALY GREAT HELP...

LET ME TRY FOR FERTHER CONDITIONS....

THANKS ONCE AGAIN....



Ashish Dhanorkar [Ashida001@gmail.com]
Tuesday, February 26, 2008

This topic is archived.


Back to support forum

Forum search