Connecting Tech Pros Worldwide Help | Site Map

Need to borrow your brain for large <table>

 
LinkBack Thread Tools Search this Thread
  #1  
Old December 6th, 2005, 02:55 PM
RC
Guest
 
Posts: n/a
Default Need to borrow your brain for large <table>

Dear Dudes,

I post this in multiple groups for opening brain storm.

Sometime I need to query the data from database server then display them
into user's browser in HTML <table>. But if the <table> is very LARGE,
let's say 20 columns, hundreds rows. Usually you have header <th> tags
on 1st (top) row and 1st (most left) column. For a such LARGE <table>.
you really want:

1) When scroll the vertical scroll bar, you want the top row header
<thead> stay in the same position, the rest of rows are move up/down
(this will include the most left column).

I am success doing this part.

2) When you scroll the horizontal scroll bar, you want the most left
column stay in the same position, the rest of columns are move
left/right (this will include the top header row).

I don't know how to do this part, need to borrow your brain for help!
Thank Q very much in advance!

You can check out my test page from

http://amazon.nws.noaa.gov/hads/test/15C2C420.html

Here is basicly what I do

<html><title>Scrollable Table</title><head>
<script language="JavaScript">
var preRow = null;
function changeRow(thisRow) {
if (preRow != null)
preRow.bgColor = "white";
thisRow.bgColor = "cyan";
preRow = thisRow;
}
</script>
<style type="text/css">
tbody { max-height: 30em; overflow: auto; }
th { background-color: lightgrey; }
th.left { background-color: cyan; }
</style></head><body>

<table border=1 width="100%">

<thead>
<tr><th class="left">col1,row1</th>..... <th>coln,row1</th></tr>
</thead>

<tbody>
<tr onClick="changeRow(this)">
<th class="left">col1,row2</th><td>col2,row2</td>......
<td>coln,row2</td></tr>
.....
.....
<tr onClick="changeRow(this)">
<th class="left">col1,rown</th><td>col2,rown</td>......
<td>coln,rown</td></tr>

</tbody>
</table></body></html>

I prefer doing this by CSS, HTML/DHTML/XDHTML, XML and little
Javascript. Java <applet> Swing JTable will be last resource,
because user has different browser, some not support Java 1.x.
And load large data into *.jar for <applet> will take time.

I did some Google search, I found two sites doing this by JavaScript.
But I prefer not to load huge file, run the JavaScript on client site.
I prefer load plain text HTML from server. Of cource, I'll keep mind
open use JavaScript grid as 2nd choice.

Here are those two good sites:

http://www.activewidgets.com/

Above site the most left column is label in sequence row number, like
preadsheet. Not very good.

http://www.theopensourcery.com/jsgrids.htm

  #2  
Old December 6th, 2005, 04:25 PM
Rhino
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>


"RC" <raymond.chui@nospam.noaa.gov> wrote in message
news:dn4d5k$g64$1@news.nems.noaa.gov...[color=blue]
> Dear Dudes,
>
> I post this in multiple groups for opening brain storm.
>[/color]
Big mistake! It is bad Usenet netiquette to crosspost to many different
newsgroups on the same problem, especially such diverse ones. The netiquette
people are going to be all over you....
[color=blue]
> Sometime I need to query the data from database server then display them
> into user's browser in HTML <table>. But if the <table> is very LARGE,
> let's say 20 columns, hundreds rows. Usually you have header <th> tags
> on 1st (top) row and 1st (most left) column. For a such LARGE <table>.
> you really want:
>
> 1) When scroll the vertical scroll bar, you want the top row header
> <thead> stay in the same position, the rest of rows are move up/down
> (this will include the most left column).
>
> I am success doing this part.
>
> 2) When you scroll the horizontal scroll bar, you want the most left
> column stay in the same position, the rest of columns are move
> left/right (this will include the top header row).
>
> I don't know how to do this part, need to borrow your brain for help!
> Thank Q very much in advance!
>
> You can check out my test page from
>
> http://amazon.nws.noaa.gov/hads/test/15C2C420.html
>
> Here is basicly what I do
>
> <html><title>Scrollable Table</title><head>
> <script language="JavaScript">
> var preRow = null;
> function changeRow(thisRow) {
> if (preRow != null)
> preRow.bgColor = "white";
> thisRow.bgColor = "cyan";
> preRow = thisRow;
> }
> </script>
> <style type="text/css">
> tbody { max-height: 30em; overflow: auto; }
> th { background-color: lightgrey; }
> th.left { background-color: cyan; }
> </style></head><body>
>
> <table border=1 width="100%">
>
> <thead>
> <tr><th class="left">col1,row1</th>..... <th>coln,row1</th></tr>
> </thead>
>
> <tbody>
> <tr onClick="changeRow(this)">
> <th class="left">col1,row2</th><td>col2,row2</td>......
> <td>coln,row2</td></tr>
> ....
> ....
> <tr onClick="changeRow(this)">
> <th class="left">col1,rown</th><td>col2,rown</td>......
> <td>coln,rown</td></tr>
>
> </tbody>
> </table></body></html>
>
> I prefer doing this by CSS, HTML/DHTML/XDHTML, XML and little
> Javascript. Java <applet> Swing JTable will be last resource,
> because user has different browser, some not support Java 1.x.[/color]

Then I strongly suggest that you keep your problem out of the
comp.lang.java.* newsgroups until you have thoroughly explored CSS,
HTML/DHTML/XDHTML, XML and Javascript to see if they can help you with your
problem.

I certainly don't want to be bothered trying to show you how this problem
can be solved via Java if you don't want to use Java in the first place.
[color=blue]
> And load large data into *.jar for <applet> will take time.
>[/color]
You don't normally load data of the kind you are describing into jars. It is
much more common to access data from databases like MySQL or DB2 via JDBC,
rather than storing the data in jars. After all, the data will presumably be
changing regularly so you will always want to access the "latest and
greatest" data; the best place to do that is in a database.
[color=blue]
> I did some Google search, I found two sites doing this by JavaScript.
> But I prefer not to load huge file, run the JavaScript on client site.
> I prefer load plain text HTML from server. Of cource, I'll keep mind
> open use JavaScript grid as 2nd choice.
>
> Here are those two good sites:
>
> http://www.activewidgets.com/
>
> Above site the most left column is label in sequence row number, like
> preadsheet. Not very good.
>
> http://www.theopensourcery.com/jsgrids.htm[/color]

I am relatively sure that the behaviour you want can be accomplished fairly
easily in Java via JTables but I am not going to waste time describing this
if you don't want to use Java in the first place.

Why don't you try the other approaches first, then come back to
comp.lang.java.gui if the other approaches don't work to your satisfaction?

Rhino


  #3  
Old December 6th, 2005, 04:49 PM
RC
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>

Rhino wrote:

[color=blue]
> You don't normally load data of the kind you are describing into jars. It is
> much more common to access data from databases like MySQL or DB2 via JDBC,
> rather than storing the data in jars. After all, the data will presumably be
> changing regularly so you will always want to access the "latest and
> greatest" data; the best place to do that is in a database.[/color]

For security reason, you really don't want people direct access your
database server from <applet>. Prefer use JDBC on server side connect
to my database server with Tomcat (servlet/jsp).
  #4  
Old December 6th, 2005, 06:45 PM
Roedy Green
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>

On Tue, 06 Dec 2005 10:43:26 -0500, RC <raymond.chui@nospam.noaa.gov>
wrote, quoted or indirectly quoted someone who said :
[color=blue]
>
>Sometime I need to query the data from database server then display them
>into user's browser in HTML <table>. But if the <table> is very LARGE,
>let's say 20 columns, hundreds rows. Usually you have header <th> tags
> on 1st (top) row and 1st (most left) column. For a such LARGE <table>.
>you really want:[/color]

There are ways of doing that with CSS/HTML but they are pretty flaky.
I tried many of the hacks and gave up because, every browser behaves a
different way.

Take the bull by the horns and put an Applet in JAWS app in your
client with a JTable and a TableModel. Then you can make it do tricks
like a circus pony.
--
Canadian Mind Products, Roedy Green.
http://mindprod.com Java custom programming, consulting and coaching.
  #5  
Old December 6th, 2005, 07:45 PM
Rhino
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>


"RC" <raymond.chui@nospam.noaa.gov> wrote in message
news:dn4k2j$sja$1@news.nems.noaa.gov...[color=blue]
> Rhino wrote:
>
>[color=green]
>> You don't normally load data of the kind you are describing into jars. It
>> is much more common to access data from databases like MySQL or DB2 via
>> JDBC, rather than storing the data in jars. After all, the data will
>> presumably be changing regularly so you will always want to access the
>> "latest and greatest" data; the best place to do that is in a database.[/color]
>
> For security reason, you really don't want people direct access your
> database server from <applet>. Prefer use JDBC on server side connect
> to my database server with Tomcat (servlet/jsp).[/color]

I wouldn't be particularly concerned about _READING_ database data via an
applet but I'd be a lot more reluctant to let people update the data.
Fortunately, that is easily prevented via GRANTs and REVOKEs on the database
side, assuming you are using something SQL based.

I'd also prefer a servlet to an applet for displaying database data but you
didn't mention servlets so I assumed you had some reason not to use them.
But I'm not sure a servlet would help you either; unless you want to use
something like Struts or something similar to handle the
displaying/scrolling of the data - and I'm not even sure Struts can do such
a thing - you'll have trouble getting the scrolling you want.

If it was me, I'd use an applet and a database for this job. I'm 90+% sure
that you can get the scrolling you want with a JTable in an applet. The
following page,
http://www.esus.com/javaindex/j2se/j...le/jtable.html,
lists
a variety of JTable techniques; one of the ones you'll need is at the "How
do I create a JTable with fixed rows?" link and costs nothing. The preceding
link, "How do I create a JTable with fixed columns?", requires you to buy a
membership from the website for $15. That might be worth it if you can't
find the tip somewhere else or infer it from the technique shown for the
fixed rows technique.

These tips are a bit dated though, going back to Java 1.2, so you may find
better techniques if you Google for them or ask at comp.lang.java.gui. Or
you can use a CSS/HTML/Javascript technique that is probably buggy and very
sensitive to which browser and browser version you are using. Your call....

Rhino


  #6  
Old December 6th, 2005, 08:15 PM
Chris Smith
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>

Rhino <no.offline.contact.please@nospam.com> wrote:[color=blue]
> I wouldn't be particularly concerned about _READING_ database data via an
> applet but I'd be a lot more reluctant to let people update the data.
> Fortunately, that is easily prevented via GRANTs and REVOKEs on the database
> side, assuming you are using something SQL based.[/color]

It's really just silly to talk about "data" this way. Obviously,
security requirements only exist for SPECIFIC data, not for data in the
abstract. If the data is my credit card number, then I'd much rather
that a security hole lets someone overwrite it (update) than read it.

In any case, whether an applet is sufficient for security depends on two
things:

1) Is it acceptable for the database server to accept incoming
connections from arbitrary IP addresses?

2) Will clients know their authentication credentials, so that the
applet doesn't need to contain its own authentication information on the
client?

If the answer to either #1 or #2 is "no", then security requirements
cannot be met, and a different approach is required.

--
www.designacourse.com
The Easiest Way To Train Anyone... Anywhere.

Chris Smith - Lead Software Developer/Technical Trainer
MindIQ Corporation
  #7  
Old December 6th, 2005, 08:35 PM
Rhino
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>


"Chris Smith" <cdsmith@twu.net> wrote in message
news:MPG.1dffaa4dc7bda76c989bf4@news.altopia.net.. .[color=blue]
> Rhino <no.offline.contact.please@nospam.com> wrote:[color=green]
>> I wouldn't be particularly concerned about _READING_ database data via an
>> applet but I'd be a lot more reluctant to let people update the data.
>> Fortunately, that is easily prevented via GRANTs and REVOKEs on the
>> database
>> side, assuming you are using something SQL based.[/color]
>
> It's really just silly to talk about "data" this way. Obviously,
> security requirements only exist for SPECIFIC data, not for data in the
> abstract. If the data is my credit card number, then I'd much rather
> that a security hole lets someone overwrite it (update) than read it.
>[/color]
Agreed! In that specific case, of course you wouldn't want people to read
and wouldn't care too much about updating.

In most cases though, at least the ones I had in mind where you are dealing
with some sort of innocuous information like products available for sale at
a website, you aren't likely to want any prohibitions against reading but
would certainly want to prevent inserts, updates and deletes. That is the
sort of situation I had in mind. I suppose I should have been more specific
and said that. It didn't occur to me though because it didn't sound like the
original poster's data was something like credit card numbers.
[color=blue]
> In any case, whether an applet is sufficient for security depends on two
> things:
>
> 1) Is it acceptable for the database server to accept incoming
> connections from arbitrary IP addresses?
>
> 2) Will clients know their authentication credentials, so that the
> applet doesn't need to contain its own authentication information on the
> client?
>
> If the answer to either #1 or #2 is "no", then security requirements
> cannot be met, and a different approach is required.
>[/color]
Agreed.

Rhino


  #8  
Old December 7th, 2005, 02:55 PM
Tex
Guest
 
Posts: n/a
Default Re: Need to borrow your brain for large <table>

> You can check out my test page from[color=blue]
> http://amazon.nws.noaa.gov/hads/test/15C2C420.html[/color]

Consider a JVM 1.1 Applet as virtually everyone has that, and then
your can build an application rather than a web page. In your example
your data appears to include:
1. Temp: Readings, Avg, Max, Min
2. Wind Speed: Readings, Hr Avg, Daily Avg, Peak
3. Wind Direction: Readings, Hr Avg, Daily Avg, @ Peak
etc.

With an applet you can download the readings and build all else
on the client machine and present it anyway you want including
scrollable tables and graphs, and the graphs can be scrolled
and the scale changed. You could add movable brackets to
a graph so user could get Avg, Min, Max, etc over any period
desired.

And the applet can download very compact data. As one example,
I had several tables which as a text file was 85K, as a binary file
was 15K which packed into a Jar as 5K.

You could pack the readings into binary and then to zip files by say
month, or quarter, or whatever is best for the application, and an
applet can spawn threads to download additional files while
working on initial data.

A TMY hourly weather file for a given city for a while year is approx
146K in binary and 72K as zip. An applet can unpack zip files and
can decode binary, e.g. TMY weather files.

So, your initial request was help building same-old, same-old,
web page w/ a little jazz via a scrollable table. With applets you
can consider building an application, and they are much more
valuable to your users.

--tex





 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.