473,385 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Automatically scrolling a dynamic table

I have an interesting issue. I need to implement a dynamic table to
mimic a select list. Each time you double click from the master list,
a row is added to the list of selected items. The list of selected
items has a column header and differentiation between odd and even
rows. This part is trivial. Clients have the ability to re-order the
list of selected items. This is also trivial: I trap the onClick event
for a row to select it. When the client clicks on the up arrow or down
array, I just swap rows in the table by removing the selected row and
inserting its contents at the new position.

The trick is that screen space is limited so that the list of selected
items can only display 6 rows including the header. If there are more
the 6 rows, the table contains scroll bars. When I try moving a
selected item down the list, the list does not automatically scroll
when the item reaches the last visible row. The item disappears from
view until you manually scroll the table.

Is it possible to automatically scroll the table when you set focus to
a row that is not visible on the screen? Is it possible to have the
table scroll by calling a JavaScript function?

Thanks in advance. HTML and JavaScript snippets are included below.
<div style='position:relative; vertical-align: top; height:150px;
width:625px; overflow:auto;
scrollbar-face-color : #D3CFC9;'>
<table class="contenttable" cellspacing="0" cellpadding="0"
rules="all"
bordercolor="#DADADA" border="2" id="_selectedItems"
style="border-color:#DADADA;border-width:2px;border-style:Solid;border-collapse:collapse;">
<tr class="columnheader">
<td colspan=>Code</td>
<td>Description</td>
</tr>
</table>
</div>

function AddGridItem(code, desc, rowid)
{
var selectedGridTab = document.getElementById("_selectedItems");

// If rowid is -1 append alse inert at rowid
if (rowid==-1) rowid = selectedGridTab .rows.legnth;
var row = selectedGridTab.insertRow(rowid);

// Column 1 is the code, column 2 is the description
var codeCell= row.insetCell(0);
codeCell.innerHTML = code;
var descCell= row.insetCell(1);
descCell.innerHTML = desc;

// Highlight even and add rows
var css = ((rowid % 2) == 0)? "even" : "odd";
row.attributes("class").value =css;
}

function swapRow(grid, rowid, offset)
{
// Get selected row, index and contrents
var currrow = grid.rows[rowid];
var name = currrow.cells[0].innerHTML;
var desc = currrow.cells[1].innerHTML;

// Selected index and new index up or down (offset is 1 or -1)
var curridx = currrow.rowIndex;
var otheridx = curridx+offset;

// Remove selected row
grid.deleteRow(curridx);

// Add row
AddGridItem(code,desc,otheridx);

// Redo odd/even rows
RepaintTable(grid);
}

function RepaintTable(tab)
{
var noOfRows = tab.rows.length;
var start=1; // Grid has a column header start at the second row
for(var i = start; i < noOfRows; i++)
{
var css = ((i % 2) == 0)? "even" : "odd";
var noOfCols = tab.rows[i].cells.length;
for(j = 0; j < noOfCols; j++)
{
tab.rows[i].attributes("class").value = css;
}
}
}

Nov 7 '05 #1
1 5561
VK

dschect...@yahoo.com wrote:
The trick is that screen space is limited so that the list of selected
items can only display 6 rows including the header. If there are more
the 6 rows, the table contains scroll bars. When I try moving a
selected item down the list, the list does not automatically scroll
when the item reaches the last visible row. The item disappears from
view until you manually scroll the table.

Is it possible to automatically scroll the table when you set focus to
a row that is not visible on the screen? Is it possible to have the
table scroll by calling a JavaScript function?


Try someObject.scrollIntoView(false) method on different parts of your
psi-element. scrollIntoView should work only on window itself but you
never know how one could extent it...

Nov 8 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: J P Singh | last post by:
Hi There We have dropdown on ASP page. The problem is we have about 900 items in the dropdown. Users scrolling through the list have become very frustrated in the past. Can someone suggest...
9
by: johkar | last post by:
I only have IE 6 and dial-up. Can you help me determine which browsers support this code? Thanks, John <html> <head> <title>Fixed Table Headers</title> <script language="JavaScript"...
44
by: Jim M | last post by:
I have had great success with using <iframe> with overflow-y set to auto. I can get a similar look with the <iframe> tag. BUT... In all cases I need to have fixed heights. Is there a way to...
1
by: angel duran | last post by:
Hi... i'm trying to accomplish this and i will be using some pictures so you can easily follow me along. I have this form <link>http://img30.exs.cx/my.php?loc=img30&image=4214.jpg</link> and in...
6
by: Jon Paal | last post by:
an excellent working solution for scrolling tables appears at this link http://www.litotes.demon.co.uk/example_scripts/tableScroll.html author has no contact page, but I have a question about...
2
by: hans.kindberg | last post by:
I have a page with a content-div that scrolls and has a dynamic height. I do this with position absolute, top and bottom. I can do this if the other parts (divs) in the page over the scrolling part...
2
by: dfdavis.mtu | last post by:
I have a table that I dynamically fill with data from a database for medical companies to be able to determine if their patients meet certain criteria. However they want a fixed header for it so...
1
by: asearle | last post by:
Dear all, I have been working to implement a scrolling table into an xml / xsl interface and so far have managed to put together an acceptable version using <thead> and <tbody> syntax. Indeed for...
6
by: =?Utf-8?B?UGF1bCBT?= | last post by:
Hi I have a screen display news data stored in a database. Sometimes the amount of data displayed exceeds the screen size. How can I make this scroll automatically over and over again ? thank...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.