Categories | Question details Back To List | ||
Urgent: addRow gets progressively slower I am havig a problem with the addRow call. it gets progressivley slower with each record I add to to. I need to add 500 rows to the grid and after it gets to about 250 rows it becomes progressvily slower to add a new row. At 320 rows it is taking almost 1/2 second to add a new row to the table. With another 180 rows to add this time really adds up. What do I need to look for to resolve this? We have a demo on Tuesday which can make or break the project and we really like the L&F of the grid component I would hate to have to take it out. srGrid = new dhtmlXGridObject('searchResultsGrid'); srGrid.setHeader("Row #,Document ID,Collection Name,Geo Ref,Load Date,Confidence,Country Confidence,Latitude,Longitude,Snippet"); srGrid.setInitWidths("50,100,75,90,75,80,80,75,75,630"); srGrid.setColAlign("center,center,center,left,center,center,center,center,center,left"); srGrid.setColTypes("ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro,ro"); srGrid.setColSorting("int,int,str,str,str,int,int,int,int,str"); srGrid.setImagePath(gridimgs); srGrid.setSkin(gridskin); srGrid.enableMultiselect(false); srGrid.init(); ... var outDataArr = new Array(); var docId = resultXml.getAttribute('docId'); var latitude = resultXml.getAttribute('latitude'); var longitude = resultXml.getAttribute('longitude'); var detailsNdxRef = '<a href="javascript:highlight('+docId+',' + latitude+',' + longitude+');">'+ (j+1)+'</a>'; outDataArr.push(detailsNdxRef); var detailsDocIdRef = '<a target="_blank" href="NewsArticle.xsql?document_id=' + docId + '">' + docId + '</a>'; outDataArr.push(detailsDocIdRef); outDataArr.push(resultXml.getAttribute('collectionName')); outDataArr.push(resultXml.getAttribute('geoRef')); outDataArr.push(resultXml.getAttribute('loadDate')); outDataArr.push(resultXml.getAttribute('confidence')); outDataArr.push(resultXml.getAttribute('countryConfidence')); outDataArr.push(latitude); outDataArr.push(longitude); outDataArr.push(resultXml.getAttribute('snippet')); // This call gets progressively slower srGrid.addRow((j+1), outDataArr); j: is our counter and the unique id outDataArr: the array of data Mike Answer posted by Support on Oct 31, 2008 10:29 The addRow is not purposed for mass adding ( after each row added, grid updates view, so it takes a lot of time ) To improve perfomance you can a) enable smart rendering mode b) use grid.parse and array of data srGrid.enableMultiselect(false); srGrid.init(); srGrid.enableSmartRendering(true); var g_data=[]; ... outDataArr.push(resultXml.getAttribute('snippet')); // srGrid.addRow((j+1), outDataArr); <= not used g_data.push(outDataArr); } grid.parse(g_data,"jsarray"); In such case all data will be stored at g_data matrix, which will be loaded by a single grid.parse call In smartRendering mode it may take a lesser than 1 sec. for 500 rows in single dataset. Answer posted by Mike on Oct 31, 2008 09:25 Thanks, I was able to generate the xml string and use the parse method. much, much better. I'm loving these tools more and more each day. Thank you again. I'm trying to get work to purchase the suite of tools for our site redesign. I am looking forward to this very much. |