Data Read Slow

I have a normal dhtlmxGrid with around 35 rows. Each row has 40 columns.

		for (i = 0; i < totalRows - 1; i++) 
		{
			curRowId = mygrid.getRowId(i);
			for (k = 0; k < totalColumns; k++) 
			{
                                   //read value and some manupulation
			}
		}

This loop takes around 15 - 20 seconds to execute. Is there a faster way to do this?

It depends on the actual logic of “read value and some manupulation”, it possible that you are issuing some commands which re-render grid multiple times.

You can try to include ext/dhtmlxgrid_fast.js and try to use

grid.startFastOperations(); for (i = 0; i < totalRows - 1; i++) ... } grid.stopFastOperations();

for (i = 0; i < totalRows - 1; i++)
{
curRowId = mygrid.getRowId(i);
for (k = 0; k < totalColumns; k++)
{

gridParams += “gridbox” + encodeURIComponent(colSep+ curRowId + colSep + k) + “=” + encodeURIComponent(mygrid.cells2(i, k).getValue()) + “&”;
}

		}

Just reading the cell value and appending it to a string. What could be causing the slow read?

Need some help here…

Just reading the cell value and appending it to a string. What could be causing the slow read?
Yes, it may be reason of slow data loading. Looping through big amount of rows is bad practice.

There are totally 35 rows and 40 columns in each row so totally 1400 values. The grid is already loaded. I need this loop while trying to save data from the grid. The “Form Integration” method of saving data also uses the same logic of reading all the cell values and is taking the same time (15-20 secs) .

Is this the expected time to read 1400 values or am I missing something?

Please help

Are you using custom excell in grid or are you using only standad cell types? Can you please provide complete demo including files which you are using to initialize grid?

Below is the code to initialize the grid. Only standard cell types are used.

mygrid = new dhtmlXGridObject(‘gridbox’);
mygrid.imgURL = “<c:url value=’/${RTA_SCRIPTS}/dhtmlx/dhtmlxGrid/codebase/imgs/’/>”;
mygrid.setColHidden(“false,false,false,false,false,false,false,false,false,false,false,false,false,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true”);
mygrid.setHeader(" ‘Date’, , ‘Type’, ‘Schedule’, ‘Actual’,A,W, ‘Total Hrs’, ‘Location’, ‘Department’, ‘Job’, ‘$’, ‘Reason Code’, ‘Punch Date’,Txn Type,deptid,jc,un,ot,bday,schDt,hdnReasonCodeId,hdnPunchTime_P,hdnUnitId_P,hdnDeptId_P,hdnJobCode_P,hdnReasonCode_P,hdnHHMMAMPM,hdnErrorCode,hdnAdjPunchId,hdnSchTimeAMPM,hdnStPunchId,hdnShStatus,errSeqNo,hdnUTC,hdnUTCdt,hdnAltJobCode_O,hdnAltWageRate_O,hdnAltJobCode,hdnAltWageRate,msdPunchErrCode");
mygrid.setColAlign(“center,center,LEFT,center,center,CENTER,CENTER,right,LEFT,LEFT,left,left,LEFT,right,right,right,right,right,right,right,right,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left,left”);
mygrid.setInitWidthsP(width);
mygrid.setColTypes(“ro,ro,ro,ro,ed,ro,ro,ro,combo,combo,combo,ro,combo,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro”);
mygrid.setSizes();
mygrid.setSkin(“modern”);
mygrid.setDateFormat("%m/%d");
mygrid.enableResizing(“true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true,true”);
mygrid.attachEvent(“onRowAdded”,mygridOnRowAdded);
mygrid.attachEvent(“onXLS”,mygridOnXLS);
mygrid.attachEvent(“onXLE”,mygridOnXLE);
mygrid.attachEvent(“onEditCell”,mygridOnEditCell);
mygrid.attachEvent(“onRowSelect”,mygridOnRowSelect);
mygrid.setOnRowSelectHandler(doOnRowSelected);
mygrid.enableUndoRedo();
mygrid.enableAutoHeight(true);
mygrid.init();
mygrid.preventIECaching(true);

Can you please provide complete demo including .js files which you are using to initialize grid and example of xml which you are using to load grid?

Have attached the demo files.

TestGrid/demo/gridDemo.html has the grid initialization.

The data read is not slow in the first load. After multiple reloads of the same page the data read time keeps increasing. In a span of 2-3 minutes (after around 10 reloads) the read time increases to 10-15 seconds. On first load the same read takes only 1-2 seconds.

I am using IE6. ieVersion.jpg has the version details of IE used.

Continuous usage for 15 - 20 minutes causes the browser to become unresponsive.

IE8 does not seem to have this problem. Data read takes only 1-2 seconds even after 15-20 minutes.

The same html when opened in Firefox gives a loadXml error. What could be the reason for this?



TestGrid.rar (55.9 KB)

Unfortunately this is known issue of IE6. IE6 is slower than other browser and do not release memory appropriately as modern browsers. Is it real use scenario when the user will need to refresh page 10 times?

By refresh i didn’t exactly mean refresh. The user navigates from one time sheet to another. So after accessing around 20 such sheets the page is too slow.

Is there any workaround?

We haven’t work around for this. IE6 has known performance issue and it cannot be fixed with JavaScript.

Alright thanks…

Why does the grid not load in Firefox?

Please check if there is any blank spaced before <?xml version=“1.0” in xml

There was a blank space, removed that still getting the error.

The xml is included in the file i had attached earlier.

Try to open tempGrid.xml file directly into the browser. Browser will point you on the line and symbol which it cannot parse.