473,406 Members | 2,378 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.

Width of a String

Hi,

I am trying to create a very long dynamic document with fixed width
for the cells of my table iin HTML, I need to truncate some of the
information that I display to fit in the table.

As the document is very long I can not use the offsetwidth
functionality of the cell because then the user will see the
information being truncated, which is not desireable, I was wondering
if there is any way of calculating the width of the text displayed in
the "risky" rows on the fly before the whole document gets rendered.

I tried to display the information in the row and then try to truncate
it right away after using the offsetwidth to see the width of the text
in pixel, but this is not working as the offsetwidth needs the whole
document to be rendered before being able to calculate the exact
value.

If anybody has any idea of how to do this on the fly I would
appreciate yor help.

Thanks

Afshin
Jul 20 '05 #1
5 6108
Afshin hu kiteb:
Hi,

I am trying to create a very long dynamic document with fixed width
for the cells of my table iin HTML, I need to truncate some of the
information that I display to fit in the table.


The default behaviour is you force width for a table cell is that the
text would then flow to create a new row of text within that cell. What
have you done which would prevent this, and why?
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #2

Hi Fabian,

thanks for the response. I forgot to mention that I want to prevent the
wrapping of the information that is why I am trying to truncate the
text.

Thanks again

Afshin

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #3
A quick way to get this done is to create a hidden div tag and upon
page load, innerHTML the string into the div, get it's width, do your
truncations, and then load the altered text from the div into the cell.
Although the page is rendered, the user doesn't see the truncation.

I hope this answers the question you've placed.

--
************************************
MUSIC24SEVEN
Pioneers of the
'Digital Entertainment Industry'
http://music24seven.com
************************************
Jul 20 '05 #4


Hi and thanks for your response.

How can you find the width of the InnerHTML of a Div BEFORE that the
page is loaded completly?

Thanks

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Jul 20 '05 #5
Afshin P wrote:
How can you find the width of the InnerHTML of a Div BEFORE that
the page is loaded completly?


You cannot. Display depends on various variables, including font
family, font size, font style, font scale and viewport size.

If you depend on any of those variables, your design is flawed if
not even borken.
PointedEars
Jul 20 '05 #6

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

Similar topics

2
by: Alex Shi | last post by:
In php, is there a way obtain the width of a charactor of a certain font? Alex -- ================================================== Cell Phone Batteries at 30-50%+ off retail prices!...
9
by: John F Dutcher | last post by:
I use code like the following to retrieve fields from a form: recd = recd.append(string.ljust(form.getfirst("lname",' '),15)) recd.append(string.ljust(form.getfirst("fname",' '),15)) etc.,...
24
by: Mike L | last post by:
This is for a Win form, in C# 2005. I want to load a datagrid, make some columns width 0, and then clean out the record I added. I get the error message, ""Index was out of range. Must be...
5
by: John Smith | last post by:
Here is my HTML table formatting code. <table border="1" width="100%"> <tr width = "100%"> <td width="33%">11asdhagdshaskgashjgahjgadhjgdjshdgasjdgajdgadjhgdgahjdgadhjsgad
2
by: Robson Carvalho Machado | last post by:
Dear friends, I'm dynamically creating a Hyperlink with spacer.gif as ImageURL that is an 1px transparent image only to determine link position, but as I create this link dynamically I could not...
2
by: strauchdieb | last post by:
hey everyone i try to figure out how to calculate string width in a textarea while typing in it. the textarea has a fixed start width. when the string gets longer as the textarea width, the...
1
by: Davo256000 | last post by:
hi there, i've recently started a student placement as a web developer and wondered if anyone could help me with the following problem: I'm using an ashx file to access messages that are stored in...
1
by: Durango2008 | last post by:
Hi, I am having a bit of trouble with my gridview table and the width of the columns. The gridview is made of Templates that contain LinkButton controls. The LinkButtons will display a string...
30
ADezii
by: ADezii | last post by:
This week’s Tip of the Week will clearly demonstrate how you can dynamically set the Drop Down List Width of a Combo Box to the length of the longest item in its Row Source. The inspiration for this...
3
by: =?Utf-8?B?QW5kcmV3?= | last post by:
Hello, friends, We use System.Windows.Forms.ComboBox in our c#.net 2005 app. We want to make the dropdown list wider than the comboBox's width. (Some items in the dropdown list have more...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.