Resizeable table columns in HTML
a2jfreak
Houston, TX Member
How would I go about making the table columns resizeable?
In all my googling I've found nothing that mentions how to allow one to resize columns in a table (just like one would do in Excel, or other spreadsheet programs) after the table has been drawn. Any help would be greatly appreciated.
In all my googling I've found nothing that mentions how to allow one to resize columns in a table (just like one would do in Excel, or other spreadsheet programs) after the table has been drawn. Any help would be greatly appreciated.
0
Comments
As for resizeable columns having varied meanings . . . maybe these screenshots will illustrate what I'm saying.
These are from Excel. The first image is just Excel with some cells filled in. The second is my resizing Column 1 . . . just like I'd like to be able to do with an HTML table column.
To do it "on the fly.. ala Excel".. it's hunt for javascript/DHTML.
[php]width="*"[/php]
can be used for a Center column in a three column layout or a right column in a two column table define. Set up the other column or columns as absolutes, preferably percentages to allow for browser dynamic resizing. Grab the source of http://www.johndanielsonii.com/pctriage/pctriage_tmplt.html, or download it for a way to run dynamically variable table widths at a browser that any browser can resize as user changes width of browser Window. Left column is percentage defined, right column is free-form width with * as width parm.
If you need both fixed and relative sizing, try a frameset explicitily defined for vertical frame areas, and not defined horizontally, with html content defined same way for containing in the frameset. I technically did not need all the table feeds in my example template, except that hr tags are best used external to tables according to Tidy.
For a table that goes from a forum, I do NOT define widths at all, I let the forum feed code do that here. Look at my "GOOD News for Team Short-Media thread, and grab the source view of a message. I used SPAN instead of widths for title row, defined overall table width as a percentage, let browsers pick how they set width themselves. tr is ROW, put multiple cells in td pairs inside each tr for multiple cell width tables, let the dang browser calc cells from overall table width. This works if you feed font defs minus any sizing of font, let the browser choose size itself.
Another way, is to feed a .pdf file, which can be created from OOo.org as printer virtual driver output. Corel Draw 11 and up can also output .pdf files. Linux can natively create pdf compatible files also. So, alternative, if you are not looking for a dynamicly updated and embedded Excel feed, is to make a .pdf and feed that.
John D.
I appreciate the help, but I believe you have misunderstood my question. Having the browser decide the width of the columns is fine, but I also want the functionality of allowing the user to resize columns as can be done in Excel.
I've already got it partially working, but I've run into a couple of snags:
1. If the data in a cell that's being resized is very long, the contents of that cell "bleed" over past the limits of the column and into the next cell (looks bad).
2. The columns will not allow me to adjust the width any less than 320px (in Mozilla. work-arounds for IE haven't been implemented so it doesn't work).
I'm pretty sure I can get it to work; it's just a matter of how closely will Excel's behavior be mimicked.
Notice the "From" column. That is as small in width as I can get it, so there's something wrong there in my opinion--it should shrink more. Also, notice the next to last cell in the same column; see how the text bleeds over into the cell in the next column?
(Notice all the spam? )
// Edit: I don't want to take full responsibility for this code. I found the major portion of the implementation on another site. Functionality has been augmented to allow for more than two columns, though, and a few other tweaks here and there. I don't recall the site off-hand, but if I can find it again I'll post a link here.
Here's the link: resizing tables
Here's who is given credit for authoring it: skiboy825
BTW, IE prefers a server gened refeed of this kind of thing, a refresh\reload event followed by new resized table feed. Mozzie can handle the dynamics with Java 2 support very nicely. IE actions are based on J++script, not Javascript of completely Sun kind, and recalcs things too much.
For reasons of being sued by Sun (and having the embarrassment of Sun winning), Microsoft is having to remove Sun stuff from "J++Script" and the Windows Scripting Host and Windows per se-- they declined to pay Sun for code use on a continuing basis, DID pay damages for refusing to pay those fees earlier. So, they came up with .NET and aspx, which relies on server-side stuff more and more-- like reload events and refeeds instead of dynamic in-window recalcing of position. STATIC Opera will work more like IE than Mozzie, also (Static opera is SANS Java 2-- yes, there are TWO Opera subforks).
John D.
I suppose I COULD grab the source, stick it in Quanta Gold 3.6+, and view it or take it and save it and view it here, BUT....
John D.
Unfortunately this forum wont allow the header style sheets, so the divs dont break down inside here like they should, look at the attachment ..
I'll take a look and see what all you did.
( sorry i dont know netscape very well, perhaps someone could add browser detection/differences into the code and re-post )
As mentioned before, the CSS classes wont work in the forum, so the text wont collapse in here as it will in the attachment. -- DreX
As far as not being seen in IE or Mozilla. I loaded it into Firefox just now and it works as well as it did two years ago. Unfortunately I had not done a great deal of work on it since then so the most recent version I have isn't much better. I have a few more projects to complete before I can get back to that, and who knows, by the time I get back to it I might find an already working version I can use. Seems like I had seen something in Bindows that worked like I had wanted, but I can't be certain.
The scripts described on the link below work with both IE and Mozilla/FireFox etc
http://methvin.com/jquery/splitter/default.html