473,396 Members | 1,724 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,396 software developers and data experts.

Optimized table with fixed size cells?

Hi all,

I am trying to write a terminal emulator using Javascript + AJAX and I
need to create an 80x25 table (each cell
contains 1 character) in which I can update the contents of each cell
very efficiently.

The tests I have done up to now seem to indicate that each time I
update the cell contents (using innerHTML), the entire table is
resized and redrawn. This makes my app very slow.

Is there a way (CSS maybe) that I can indicate to the table that the
cells are of fixed size and that any update of cell contents only
requires a redraw of that particular cell?

Thanks a lot,

Patrick LeBoutillier

Feb 4 '07 #1
3 4318
On 2007-02-04, patl <pa******************@gmail.comwrote:
Hi all,

I am trying to write a terminal emulator using Javascript + AJAX and I
need to create an 80x25 table (each cell
contains 1 character)
There's a first time for everything!
in which I can update the contents of each cell very efficiently.

The tests I have done up to now seem to indicate that each time I
update the cell contents (using innerHTML), the entire table is
resized and redrawn. This makes my app very slow.

Is there a way (CSS maybe) that I can indicate to the table that the
cells are of fixed size and that any update of cell contents only
requires a redraw of that particular cell?
How particular implementations optimize reflow is not accessible. You
could try using innerText or replaceChild instead of innerHTML, but it
might well not make any difference.

Instead of using a table you could just make each character a <span>,
each line a <divand use a monospace font (if you want columns all the
same width). Then the browser is more likely to reflow only one line at
at a time. I suppose 25 tables with one row each for each line might
also work.
Feb 4 '07 #2
"patl" <pa******************@gmail.comwrites:
Hi all,

I am trying to write a terminal emulator using Javascript + AJAX and I
need to create an 80x25 table (each cell
contains 1 character) in which I can update the contents of each cell
very efficiently.

The tests I have done up to now seem to indicate that each time I
update the cell contents (using innerHTML), the entire table is
resized and redrawn. This makes my app very slow.

Is there a way (CSS maybe) that I can indicate to the table that the
cells are of fixed size and that any update of cell contents only
requires a redraw of that particular cell?
How about 25 divs or 80 spans (untested):
<div class="row">
<span id="r00c00"></span><span id="r00c01"></span>...
</div>
<div class="row">
<span id="r01c00"></span><span id="r01c01"></span>...
</div>
....

your CSS can set

div.row span {
width: 1em;
}

and if you still get re-flow, why not add IDs to the row divs
(id="r00", id="r01"...) and position everything absolute (using ems of
course) or maybe just absolutely positioned rows:

div.row { position: absolute; left: 0; }
#r00 { top: 0em; }
#r01 { top: 1.2em; }
#r02 { top: 2.4em; }
....
--
Ben.
Feb 5 '07 #3
Scripsit patl:
The tests I have done up to now seem to indicate that each time I
update the cell contents (using innerHTML), the entire table is
resized and redrawn. This makes my app very slow.
This isn't really an HTML question, and other answers in this thread might
point to better directions, but...
Is there a way (CSS maybe) that I can indicate to the table that the
cells are of fixed size and that any update of cell contents only
requires a redraw of that particular cell?
Yes, in CSS you can set table-layout: fixed for a table, and a browser will
then use the widths calculated for cells in the the first row as column
widths, no matter what the contents of other cells might require. The
primary reason is to speed up rendering. (When a table is very large, it
takes time for a browser to read all rows and analyze the width requirements
of all cells before deciding on the column widths.) It _might_, however,
affect the rendering in your case, too.

--
Jukka K. Korpela ("Yucca")
http://www.cs.tut.fi/~jkorpela/

Feb 5 '07 #4

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

Similar topics

2
by: Danny | last post by:
Hello I am trying to keep a table or row a fixed size. I have a javascript that assigns different images to the SRC of the main image, but the table will resize whne there is a smaller height...
11
by: Linny | last post by:
Hi, I need some help in declaring an array of pointers to array of a certain fixed size. I want the pointers to point to arrays of fixed size only (should not work for variable sized arrays of the...
3
by: gscott66 | last post by:
Hello, I am fairly new to design and in particular CSS. I have a site with two tables that I cannot seem to get sized correctly. When you view the link, you'll notice that there is a tremendous...
0
by: Ken Varn | last post by:
I have a managed C++ assembly in which I need to interact with some 'C' APIs that take fixed size 'C' data blocks. I need to wrap these data blocks into a managed object. It seems like a lot of...
5
by: collection60 | last post by:
Hi people, I am writing a library that will implement a binary file format. Well... I'm thinking, as a design, it would be nice to have my library able to promise to not use more than a...
8
by: chrisben | last post by:
Hi, If I am not sure how many items will be in my Hashtable/ArrayList dynamically (multiple threads can add/remove/check the item), however, I can estimate the total number will not exceed...
2
by: neuneudr | last post by:
Hi everybody, I'm scratching my head with a CSS problem. I want to have the following (the two pics have these size for a good reason, the whole point of the page is basically to show these...
3
by: jerrygadd | last post by:
Hi can anyone please help? I have a need to make a table of fixed size, containing three rows, where the middle row auto expands to fill the remaining space between the top and bottom rows. ...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.