• Home
  • About
  • Resume

Speed up UltraWebGrid with direct DOM access

By , 02/21/2012 1:04 AM

Infragistics UltraWebGrid offers rich client-side programming model, but often it can be extremally slow. As an example consider a simple task: Given a particular Row ID hide the rest of the grid rows, keeping only this row visible.

Using UltraWebGrid’s CSOM (Client Side Object Model) JavaScript code looks like this:

var oGrid = igtbl_getGridById('xMyGrid');    // Get reference to grid object

for (var sRowID in oGrid.Rows) {   // Looping thru all rows in grid's rows collection

   if (sRowID != sSelectedRowID) {   // If current row ID is not given ID
      igtbl_getRowById(sRowID).setHidden(true) // Get reference to row and hide it
   }

}

The code works – it really does. But to loop thru 50 rows in this manner can take 10-15 seconds, not something your user will be happy about when instant action is expected.

Now let’s revise the above code a little:

var oTable = igtbl_getGridById('xMyGrid').Element;   // Get reference to grid's TABLE

for (var I = 0; I < oTable.rows.length; I++) { // Looping thru all rows in HTML Table
   
   if (oTable.rows[I].id != sSelectedRowID) { // If current row ID is not given ID
      oTable.rows[I].style.display = 'none' // hide HTML Table row
   }

}

Because the second code block doesn’t have to jump thru hoops of Infragistics JS library (direct row reference instead of loaded igtbl_getRowById, simple CSS instead of setHidden) it only takes fraction of a second to execute.

This example shows, that using Document Object Model instead of Infragistics Object Model can give you a tremendous performance boost. This replacement is not always possible, but when it is – the effect is amazing.

3 Responses to “Speed up UltraWebGrid with direct DOM access”

  1. Roger says:

    In my case the performance turned to be normal changing this setting in IE8:

    Under “Tools” select “Compatibility view settings”. Then UNCHECK “Display intranet sites in Compatibility View”.

    It seems that this “Compatibility View” generated Incompatibility…

    The reason it didn’t happen while I was debugging was that it used the Visual Studio ASP.net development server, on my own machine, thus, I wasn’t accessing the intranet.

    I hope it helps.

  2. Roger says:

    I’ve found a better workarount to FORCE IE to not activate the compatibility mode: simply add this in the head section of your webpages (between the minus than and the greater than symbols) :

    meta http-equiv=”X-UA-Compatible” content=”IE=EmulateIE8″

  3. Yuriy says:

    @Roger You can do even better:

    meta http-equiv=”X-UA-Compatible” content=”IE=Edge″

    This will force IE to render to whatever latest engine is available IE9, IE10 etc.

    .. On a completely unrelated topic – thanks for pointing out that comments were redirecting to login, I didn’t realize that. Should be fixed now.

Leave a Reply

Panorama Theme by Themocracy