473,406 Members | 2,390 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Urgent: Problem with client-side insertBefore; too slow

Client-side problem scripting problem. I have a table of about 300 rows with
many columns. User chooses to sort on one column. Sort is very fast (I do
this by extracting the column data along with its index and then using the
array sort with). The problem is with the following code that I took from
MSDN's DHTML Dude's article:
//TheBody is is a tbody with id "TheBody". It is at the end of the table
//Â*Â*Â*andÂ*isÂ*whereÂ*weÂ*areÂ*insertingÂ*theÂ*sor tedÂ*rows.
//aSortedArray - contains a string with with "|" separators. The last one
is
//the index into the original rows to be sorted.

Â* Â* Â* Â* var i, r, b, d, s,j,a;

Â* Â* Â* Â* b = TheBody;
Â* Â* Â* Â* var rtr=ResultsTable.rows
Â* Â* Â* Â* var ri;
Â* Â* Â* Â* //Display the sorted rows
Â* Â* Â* Â* for (i=1; i<count; i++) {
Â* Â* Â* Â* Â* a=aSortedArray[i-1];
Â* Â* Â* Â* Â* j=a.lastIndexOf("|");
Â* Â* Â* Â* Â* ri=parseInt(a.substr(j+1,3).replace(^0*,""));
Â* Â* Â* Â* Â* r = rtr[ri].cloneNode(true);
Â* Â* Â* Â* Â* r.id = "NewRow" Â* Â* Â* Â* Â* Â* Â* //for convenience in finding all
new ones
Â* Â* Â* Â* Â* b.insertBefore(r, null); Â* //<<<<<<<<<<<this is very slow!
Â* Â* Â* Â* }
It takes about 20 seconds on a 2GHz machine to display the rows.

I would really appreciate any help

Thanks
Jul 21 '05 #1
1 1532
Nicole Schenk wrote:
Client-side problem scripting problem. I have a table of about 300 rows
with many columns. User chooses to sort on one column. Sort is very fast
(I do this by extracting the column data along with its index and then
using the array sort with). The problem is with the following code that I
took from MSDN's DHTML Dude's article:
//TheBody is is a tbody with id "TheBody". It is at the end of the table
//Â*Â*Â*andÂ*isÂ*whereÂ*weÂ*areÂ*insertingÂ*theÂ*sor tedÂ*rows.
//aSortedArray - contains a string with with "|" separators. The last one
is
//the index into the original rows to be sorted.

var i, r, b, d, s,j,a;

b = TheBody;
var rtr=ResultsTable.rows
var ri;
//Display the sorted rows
for (i=1; i<count; i++) {
a=aSortedArray[i-1];
j=a.lastIndexOf("|");
ri=parseInt(a.substr(j+1,3).replace(^0*,""));
r = rtr[ri].cloneNode(true);
r.id = "NewRow" Â* Â* Â* Â* Â* Â* Â* //for convenience in finding all
new ones
b.insertBefore(r, null); Â* //<<<<<<<<<<<this is very slow!
}
It takes about 20 seconds on a 2GHz machine to display the rows.

I would really appreciate any help

Thanks

Problem solved by not using insertBefore. Instead I create a fragment first,
insert into this fragment and then add the fragment after the loop.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Chris | last post by:
Hi, I developed a COM+ Server application on my XP machine. It works excellent. I exported as server application and then installed it in a windows 2003 server. I then exported it as a Proxy...
9
by: Stefan Bauer | last post by:
Hi NG, we've got a very urgent problem... :( We are importing data with the LOAD utility. The input DATE field data is in the format DDMMYYYY (for days) and MMYYYY (for months). The target...
8
by: Mike | last post by:
Hello, I have a few rather urgent questions that I hope someone can help with (I need to figure this out prior to a meeting tomorrow.) First, a bit of background: The company I work for is...
1
by: Yuri Ch | last post by:
Hi all, I'm quite new in C# and have no expirience in sockets. I have no idea how to implement the following app, but for expirienced developer, I suppose it should be very trivial... I have...
1
by: Manish Songar via .NET 247 | last post by:
I am using asp.net. I am not storing image in sql server.I store all the image in one folder. I want to access image from that folder to my client machine. Images folder (\Orchid_Image) store in...
1
by: situ | last post by:
hi all, this is the procedure i have created CREATE PROCEDURE XIREL2.proc_size_2 (p_dummy CHAR(1)) SPECIFIC XIREL2.proc_size_2 DYNAMIC RESULT SETS 3...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
10
by: Teja | last post by:
HI all, I have a problem in accesing COM objects in threads. To be precise, lets assume that I have a class GenericFunctions which is defined as follows: import win32com.client, pythoncom,...
1
by: rajesh.us.it.recruiter | last post by:
Hi Guys/Partners, We have a URGENT Requirement for Perl Programmer with H1 visa in India/US for one of our prestigious Client. Location : New Jersey Requirements : Should be very strong in...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.