• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

offsetWidth problem

 
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, I got 'offsetWidth' problem. I have a table, then I try to get each cell offsetWidth. But I always get '0'. What will affect this value? CSS, style setting?

Very confusing. Anybody has same experience before?

Thanks.
 
Ranch Hand
Posts: 71
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Depends on your requirements, there are many ways to style this.
One example:

td { padding:.5em; }

--Nimchi
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for reply.

But my question is, 'offsetwidth' not work properly. always 0.

Thanks.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
http://www.quirksmode.org/js/doctypes.html

Eric
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Eric.

I solve this problem. The key is like java multi-thread, I have a huge table, originally, I have a after-load js event where I get offsetwidth value. The tricky thing is, when IE finds this huge table, it will create another thread to go next element, so when IE return offsetwidth value, acutally IE not finish loading the table, so, the offsetwidth value is 0.

The solution is , put those after-load js event into a button event.

This time IE finally looks like having logic.

Thanks.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ah, did not think of asking when you were checking the width. Browsers tend to not have a size until after the page has rendered completely. Some even have issues when style sheets are involved.

Have you figured out what you are doing for the printing issue yet?

Eric
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks, Eric,

yes, I am working on a huge table printing. I find a solution. After rendering table, I compute each cell width, then I split (actually, use block and none ) the table, assuming the page size is 750px in Landscape layout. Then print.

Now I am concerning the performance. The table has 400*47 cells. It takes a while.



In above coding, could I have a simpler API to turn whole table into 'block', not using for-loop ?

Thanks.
 
Eric Pascarello
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are you doing exactly? Just trying to get this through my head with your looping with block.

Are you showing and hiding columns based on width?

Eric
 
Edward Chen
Ranch Hand
Posts: 798
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
after I 'none' the table, I need to reset the status back to 'block'. So I have coding above.

I am looking for something like this 'table.allCells.display=true'.

Thanks.
 
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
make all your cells to have the same class name, and the use info from the following link:

http://www.faqts.com/knowledge_base/view.phtml/aid/2147/fid/128

At least you will not have to loop through all your cells.
 
reply
    Bookmark Topic Watch Topic
  • New Topic