1

im having table with more than 1k rows and more than 7 columns, trying to parse into array object, i tried using jquery

$(tableSearch).each(function () {
    $('tr', $(this)).each(function (key, tr) {
        var self = this;
        var obj = new Object();
        var rowPos = 0;
        $('td', tr).each(function (rowPos) {
            obj[_self.colModel[rowPos].name] = $(this).html();
        });
        obj['Key'] = 'Rec-' + key;
    });
});

in FF it takes 300 milli seconds, but in IE its taking 60 seconds :(

as u can compare its around 200 times slower.

is there any way to get performance in IE. i tried raw javascript methods also still in IE efficiency is not achieved.

help me!!!!!!!.. how can i get similar performance in all browsers.

THANKS in Advance

user113716
  • 318,772
  • 63
  • 451
  • 440
scb
  • 170
  • 5
  • There is no way to get around this. You should consider running the code as a background thread if the task can be deferred http://stackoverflow.com/questions/1160137/execute-background-task-in-javascript OR show user some kind of progress bar.. – Jishnu A P Aug 16 '11 at 12:53
  • A Porsche is faster than a turtle, that's life. As long as a turtle can't run faster you'll need to speed-down the Porsche to get similar speed. – Dr.Molle Aug 16 '11 at 13:06
  • Can't you leave the data in the table? $("#tableId tr").eq(1000) – mplungjan Aug 16 '11 at 13:11
  • 1
    IM TRYING TO GENERATE GRID(I HAVE TO USE JQGRID) FROM A TABLE OF DATA. SO I NEED TO PARSE THAT TABLE TO ARRAY OBJECT. I DONT HAVE ANY OTHER CHOICE. AS I WILL NOT HAVE ANY ACCESS TO THE WAY THIS TABLE IS GENERATING. ITS A HUGE SECURE SYSTEM. WHICH WILL GIVE ONLY TABLE OF DATA. WHERE I NEED TO ADD ALL OPERATION LIKE ADD, DELETE BUTTONS DYNAMICALLY.. – scb Aug 16 '11 at 13:19
  • Your SHIFT-Key seems to be broken – Dr.Molle Aug 16 '11 at 13:25
  • 1
    Have you tried to do it without jQuery? Maybe it´s faster when it is a simple for loop. Maybe.. ^^ – Van Coding Aug 16 '11 at 13:56

1 Answers1

0

i got the solution IE can be faster if we implemented this way

table = document.getElementById("myGrid");
    for (i = 0; i < table.rows.length; i += 1) {
       var rowData = new Array();
       row = table.rows[i];
       for (j = 0; j < row.cells.length; j += 1) {
           cell = row.cells[j];
           rowData[j] = cell.innerHtml
       }
       obj.push(rowData);
    }

Note: disable debug mode if ur using any debugger.

then IE seems to be reasonable but cant be faster than FF or safari

scb
  • 170
  • 5