Forum Moderators: open

Message Too Old, No Replies

Overflow / Max lines=2 in TD

Excel style editing in a TABLE

         

Csaba

6:12 pm on Mar 14, 2003 (gmt 0)

10+ Year Member



I hope I get the details right on this...

This only applies to IE 5.5 & 6 since they're the only ones that support contentEditable. I have a table that is generated on the fly, and I want to have the entries in the table be editable. No problem, we just put in <td><span contentEditable>Entry is here</span></td> for each table element. What I'd like to do is have some Excel style layout / editing capability.

I have three questions and I'll be happy if any are answered (javascript and responding to events may be presumed):

1) QUESTION: Is there any way to have content flow "over" the next cells IF THEY ARE EMPTY. Setting colspan=appropriateNumber is not sufficient since a person should be able to edit the blank cells, too. Possibly some transparency type of thing?

2) If I get lots of data in a cell, it would be rude to the other cells to display it all. So I only want to show the "beginning" of the data. If I understand it right, that means table-layout is fixed (so that I can deal with overflow) which implies I have fixed width columns. I can live with that. But I find single line entries for long lines confusing (when you are editing them) so my QUESTION is: How do I set the (maximum) number of allowable lines to be 2? The point is, this is a system dependent setting and I shouldn't be relying on absolute units.

3) QUESTION: Regarding either 1 or 2, how can I tell if overflow has happened?

Thanks for any tips,
Csaba Gabor from New York

tedster

3:05 am on Mar 15, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Csaba, welcome to WebmasterWorld,

This is more using a web page as an application platform rather than "merely" a brower. It's good you're focused on IE, because this is pretty much a Microsoft direction.

On question #1, you may be thinking too much about the way an Excel screen dispays its cells. An HTML table cell can continue to enlarge vertically without limit - it doesn't need to overlap into neightboring cells.

On question #2, you may be able to approach this by placing a fixed size <div> within the table cell - and setting overflow:auto on that div. I've never tried this approach myself, but I think it's the direction you need to go. It's usually a major problem if you try to over-control a table's exact measurements.

Browsers, including Explorer, have a much needed flexibility in how they render tables. No matter how hard you try to control, the user's browser will still override.

Csaba

4:08 am on Mar 15, 2003 (gmt 0)

10+ Year Member



Tedster, thanks for the welcome.

Regarding the reply to #1. If the table cell has an entry that is thousands or even several hundred characters long, then having the table cell enlarge automatically is exactly what I don't want. It would mean that I would only see a few or possibly just that one row of the table. Not good. This is what the overflow control is for. Which leads us to:

#2. Yes, I am using the overflow setting now. That truncates what appears. But I want two lines to appear, not the default one line. After testing the one line variant out, I find that it is confusing to know when something is overflowing, and the editing process is also confusing for the user (me). Allowing the two rows makes a huge amount of difference. So I am still asking my question: How do I tell the <div> or <span> or <td> element that it should be two lines high and not just 1 line high?

In my dealings with tables, they are generally paying attention to the settings that I specify, and I have no complaints. It's up to me to figure out those settings, of course.

As far as the IE direction goes, you are right on the mark that this is an application (One could argue that any page using javascript falls into this camp). But as far as it being a strictly IE direction, it's interesting to me that there were recently (a few months back) major debates within some Mozilla groups about what Mozilla should do about this contentEditable business. It's not in the DOM spec - what to do? I propose we don't debate this. I have a pretty utilitarian purpose here. But philosophical underpinnings aside, I think this functionality will appear in the other browsers.

Csaba