Click to See Complete Forum and Search --> : Persistent table headers on Web pages
rscop
11-25-2002, 10:45 AM
I'm building a web page with a table with many rows (dynamically via JSP - the number of rows, number of columns, width, etc. may vary everytime the web page is invoked). I'm trying to find a way to keep the table headers static/persistent on the web page as the user scrolls down through the rows. I have read about <thead> and <tbody> and layers, but I cannot seem to find a solution. Can anyone help?
Stefan
11-25-2002, 10:57 AM
There are many ways to do what you want.
An URL to what you got now would help narrow down the options to something that would fit your specific page.
rscop
11-25-2002, 12:54 PM
Unfortunately the url is on our intranet inside a firewall. however, here is the code - hopefully this helps:
<% Vector v = (Vector) request.getAttribute("rows");
ArrayList columnlist = (ArrayList) request.getAttribute("columnnames") ; %>
<p> Number of results: <%= v.size() %>
<table width="100%" border="1">
<thead>
<tr>
<% for (int i=0; i < columnlist.size(); i++) { %>
<th bgcolor="#000099"><b><font face="Verdana, Arial, Helvetica, sans-serif" size="1" color="#ffffff">
<%= columnlist.get(i) %></font></b></th>
<% } %>
</tr>
</thead>
<tbody>
<% ArrayList row = new ArrayList();
String content = " ";
for (int i=0; i < v.size(); i++) {
row = (ArrayList) v.get(i);
%>
<tr>
<% for (int m=0; m < row.size(); m++) {
content = (String) row.get(m);
if ( (content==null) || (content=="null") || (content=="") )
{ content = " "; }
%>
<td bgcolor="#eeeeee"><font face="Verdana, Arial, Helvetica, sans-serif" size="1" ><%= content %></font></td>
<% } %>
</tr>
<% } %>
</tbody>
</table>
Stefan
11-25-2002, 08:45 PM
Auch.
That are some pretty broken webpages you got there. Ever thought about actually learning HTML before advising people of how to use it? :rolleyes:
Anyway rscop here is an example of something that might give you a idea or two of how to do it.
http://hem.bredband.net/stehus/logd/home.html
It's simple and valid CSS/(X)HTML to create a subsection of the page to be scrollable.
Adapting it to your table shouldn't be too much of a problem.
To get the same width on the column of the headersection as the table section in the freely scrollable area you could check the widths of the generated columns.
James L.
11-28-2002, 07:38 PM
Wow... and the hits just keep on coming.
Stefan, your advice has always been great, as a matter of fact you just answered some of my questions the other day but I have got to say I agree with the above post, though I definitely would have worded it differently.
You have knowledge to share and you can explain it well, but when you lead off with an insult most people just ignore the knowledge and think you're an idiot.
People who are trying to help out another person shouldn't be belittled. Who comes away looking like the idiot... you or the guy who was just trying to help?
Stefan
11-28-2002, 08:10 PM
Originally posted by James L.
but I have got to say I agree with the above post
Too bad. :(
This is not the first post by Dave Clark in a very offensive tone when people try to point out that he has some errors in his code, for the benefit of both himself as well as others.
In fact there is a very long thread around here
http://forums.webdeveloper.com/showthread.php?s=&threadid=77
were he persistantly maintains that you should use invalid code inspite of there beeing 100% valid ways to do things.
As long as he continues to post crappy invalid code with total disregard to that he is teaching newbies to do things the wrong way I will continue to point it out so people don't make the mistake of blindly copying his code (and wonder why their webpage fails miserably in most webbrowsers out there).
That Dave takes offence when I do that I really don't care about. I care more about helping people to get valid solutions that works in all browsers then Dave's ego getting hurt.
Hope this explanation will make you see things in a slightly different manner. :)
Stefan
11-29-2002, 03:01 AM
Originally posted by Dave Clark
[B]Bashing someone upside the head with a sledgehammer is *not* any rational person's idea of "trying to point out" something to them.
That would be this post then
"But Charles have already showed exactly how you should add different scriptlanguages to a page the CORRECT way, so why do you instist on using a non valid way? "
Real big sledgehammer there. :rolleyes:
Hmmm... Not only are you deluding yourself into thinking that you know how to 100% solve the dual script language scenario I was talking about, in that other post, but
The valid way to use several scriptinglanguages on the same page is clearly shown in that thread.
To bad you are still the only 1 unable to see it.
However, just a note... I haven't taken any personal offense at all.
The language and personal attacks you use points at something else.
A few "highlights"
> you also are deluding yourself into thinking you're good at spelling, too.
> Yeah, and you're full of more of something
> You really need to get a psychiatrist to help you with your problem.
> You have such an inferiority complex that you can't feel good about yourself without putting someone else down first.
> Get a life, loser!
It's pretty clear you are as unoffended as you are able of take in resonale arguments and facts.
BTW, how is it going with finding documentation in the other thread? Found anything yet? :rolleyes:
Stefan
11-29-2002, 06:45 AM
Originally posted by Dave Clark
[B]See? That's the kind of blind-folded insults that you are good at -- and, probably, not much else. I clearly stated that I wasn't even looking for any documentation.
No, you first started a big song and dance how you should return with that documentation a few days later.
"Check back in a couple of days and I'll have a response here from Microsoft for you. :D"
And in relpy to others in the thread you also made statements like
"Get your documentation-only facts straight, because those who have real, live experience may know more than you on some subjects. :p"
Only later (when you pehaps realized even yourself that you were pushing proprietary crap code for no good reason at all) did you change your story to "I wasn't even looking for any documentation."
You talk a lot but you obviously don't even bother with cheking up on the facts before you state "how it is".
James L.
11-29-2002, 07:55 PM
Well, didn't I step into the middle of a battle royal! :)
I am not going to comment more either way as this is obviously personal, but I do stand by my comment that people who are looking for help or trying to offer help shouldn't be belittled.
e.g.
A person who asks how to use tables for page layout shouldn't receive a reply that basically says:
"Using tables for page layout is stupid...only idiots do that"
When it could instead this could be stated:
"Maybe you didn't know that you can use CSS to lay out pages, it works a bit better and is the W3 way to go".
(Speaking of which refer to my post under CSS!)
I hope to continue to learn from everyone on this site who can offer some assistance.
rscop
12-02-2002, 10:36 AM
Just would like to say 'thanks' for taking the time to share your knowledge ... your expertise helped me, my question has been answered and I know where I need to focus to further develop my 'web' skills. Sorry about stirring up the negative stuff.
Rita
Stefan
12-02-2002, 12:00 PM
Originally posted by rscop
Sorry about stirring up the negative stuff.
Dont' worry, that has nothing to do with you :)