3.2.0

Have a column automatically stretch to data length

I am building a grid with dynamic data... columns consist of persons name, company, date joined etc...

Currently I have a set column width for "Company" say 150px.

Results Are:

Company ABC
Company ABCD
Company ABCDEFGHIJKLMNO Extra Long Company Name

The last result gets cut around "J" and the user would have to stretch the column width manually to see the rest of that companies name. Is there a way to dynamically set the column width to the "worst case" length of that column or am I forced to enter a static width of 300px. Which if there is a company entered down the road, manually update it to 350px, 400px, etc...
Joe
October 3,
You might find the following posts interesting:

http://www.activewidgets.com/javascript.forum.19561.4/contribution-double-click-header-separator.html
http://www.activewidgets.com/javascript.forum.14216.2/double-click-the-separator.html

Ankur
Ankur Motreja
October 4,
Ankur,

I found the second link useful but, I am currently incorporating link tags in MyData. So when I double click the column stretched to the width of the cell data not the viewable data. ie.

Grid displays: This is a link
But appears to be stretching to length of tags: <a href="....."><b>This is a link</b> </a>

So instead of getting: (pipes are contain column sides)

| This is a link |

I get

| This is a link |

1. Anyway possible to have it auto stretch not on a double click?
2. Anyway possible to have it adjust based on viewable data?

I appreciate the quick response.
Joe
October 4,
ops... removed spaces on post. Second example appears as:

|This is a link____________|
Joe
October 4,
Hi,

1. Anyway possible to have it auto stretch not on a double click?

It should be possible to put the code under obj.onCellDoubleClicked into another function and call it when you display the grid.
For example, if you put all the code into function stretchColumn(col) , you can then call stretchColumn passing it each column number right after you display the grid so that all the columns are resized.

2. Anyway possible to have it adjust based on viewable data?

I did a bit of searching and looks like http://javascript.internet.com/snippets/remove-html-tags.html has a small piece of code to remove html tags from a piece of text.
You will have to integrate this code into the code under obj.onCellDoubleClicked near the line curChars = myData[i][col].length

Ankur
Ankur Motreja
October 5,

This topic is archived.

See also:


Back to support forum