wood burning stoves 2.0*
The moose likes HTML, CSS and JavaScript and the fly likes noWrap property for TD tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Bookmark "noWrap property for TD tag" Watch "noWrap property for TD tag" New topic
Author

noWrap property for TD tag

Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Hey, I have a requirement to add my TD dynamically and I am able to set all the required properties to TD dynamically using javascript except one.
How to add property which says not to wrap td data inside table..
i.e something statically we do using <TD nowrap>
I tried using javascript as
element.style.noWrap = true
and
element.noWrap = true

assume element in valid TD object here.

Appreciate if any one could reply..


Rizwan
SCJA, SCJP, SCWCD, SCBCD, SCDJWS.
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Try

elem.style.whiteSpace = "nowrap";

Eric
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Thanks for your reply Eric.
But that didnot work. I use IE6.
Ajith Vijayan
Greenhorn

Joined: Jan 04, 2007
Posts: 1
Please try with document.formname.getElementById("elementName").style.wordWrap="normal"
the syntax elementId.style.wordWrap="break-word" is used for introducing word wrap. I think this is the reverse case
Joel Jorgensen
Greenhorn

Joined: Oct 13, 2006
Posts: 22
This may not be quite what you're looking for, but if you hide the overflow it won't wrap. The potential problem with this is that you will probably also need to explicitly set the width and height of the element (otherwise it will collapse completely) e.g.


There may also be a way to set just the horizontal overflow (elem.style.overflowX, maybe) in which case you would only need to specify the width, e.g.

[ January 04, 2007: Message edited by: Joel Jorgensen ]

Go is to the fountain.
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Hey Ajith, Thanks for reply. Welcome to Javaranch. Unfortunately your post didn't work.
Hey Joel, your solution also didnt work for me.. Is that something you tried and working?
Liu Zhixiang
Ranch Hand

Joined: Aug 12, 2006
Posts: 32
elem.style.whiteSpace="nowrap"; //It's right!!

But this attribute didn't work as you set the elem's width.
[ January 05, 2007: Message edited by: Liu Zhixiang ]

I Think Therefore I Am
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
Thanks Liu.
Hey Eric, your solution worked. I was mentioning it on the TR object instead of TD object. After applying on TD object, it worked.
Thanks for your help as always..
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
FYI: I hate CSS!

Eric
Rizwan Mohammad
Ranch Hand

Joined: Sep 02, 2005
Posts: 445
FYI: I hate CSS!

What is the alternative?
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15376
    
    6
Hiring omeone else to code it!

Eric
 
Consider Paul's rocket mass heater.
 
subject: noWrap property for TD tag
 
Similar Threads
Fetching checked data from html:checkbox inside logic:iterate
jstl mapped properties
headache with validation framework
How to validate that in each row how many checkboxes are checked
Struts TextBoxes