473,513 Members | 2,559 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Moving rows in a table

wmc
I need to convert a desktop app to the web and would appreciate input
from web developers who have created anything similar, or could point me
to some resources on the web (I haven't worked on web apps for several
years and feel kind of out of touch with all the latest stuff going on...)

A simplified version of What I need to convert is the following... I
have a grid with data in a window which holds a list of rules. The rules
are added from another data control. The rules are order dependent and
so I need to use a toolbar that contains first/up/down/last and changes
the position of the selected rows and the row numbers. There are never a
lot of rows, 20 to 30 would be a lot in this app.

My question is, what's the best way do something on the client-side that
will refresh the view. E.g. say I have 5 rules which are contained in an
html table or an xml file if I have a ui that looks like this.

__________________________________________________

1 Rule_foo foo_attrib...
2 Rule_bar bar-attrib...
3 Rule_one one-attrib...
4 Rule_two two_attrib...
5 Rule_tre tre-attrib

Move First | Move Up | Move Down | Move Last

__________________________________________________


Is there a good way to avoid a brute force, server redraws everything
approach.

Thanks...

williamc
Dec 27 '05 #1
3 13178
wmc wrote on 27 dec 2005 in comp.lang.javascript:
__________________________________________________

1 Rule_foo foo_attrib...
2 Rule_bar bar-attrib...
3 Rule_one one-attrib...
4 Rule_two two_attrib...
5 Rule_tre tre-attrib

Move First | Move Up | Move Down | Move Last

__________________________________________________


<table>
<tr onclick='thisrow(this)'><td>1 -------------
<tr onclick='thisrow(this)'><td>2 -------------
<tr onclick='thisrow(this)'><td>3 -------------
<tr onclick='thisrow(this)'><td>4 -------------
<tr onclick='thisrow(this)'><td>5 -------------
</table>

<script type='text/javascript'>
var whichrow=false

function thisrow(x){
if (whichrow) whichrow.style.backgroundColor='transparent'
whichrow = x
whichrow.style.backgroundColor='yellow'
}
</script>
<button onclick='if (whichrow)
whichrow.parentNode.insertBefore(whichrow,
whichrow.previousSibling)
else alert("First select a row, please!")'>
Move Up</button>

<button onclick='if (whichrow)
whichrow.parentNode.insertBefore(whichrow,
whichrow.parentNode.firstChild)
else alert("First select a row, please!")'>
Move First</button>

ie6 tested.

The Move up rotates, I don't know why!

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 27 '05 #2
Evertjan. wrote on 27 dec 2005 in comp.lang.javascript:
wmc wrote on 27 dec 2005 in comp.lang.javascript:
__________________________________________________

1 Rule_foo foo_attrib...
2 Rule_bar bar-attrib...
3 Rule_one one-attrib...
4 Rule_two two_attrib...
5 Rule_tre tre-attrib

Move First | Move Up | Move Down | Move Last

__________________________________________________


<table>


more complete:

<table>
<tr onclick='thisrow(this)'><td>1 -------------
<tr onclick='thisrow(this)'><td>2 -------------
<tr onclick='thisrow(this)'><td>3 -------------
<tr onclick='thisrow(this)'><td>4 -------------
<tr onclick='thisrow(this)'><td>5 -------------
</table>

<br>
<button onclick='moverow("up")'>Move Up</button>
<button onclick='moverow("down")'>Move Down</button>
<button onclick='moverow("first")'>Move First</button>
<button onclick='moverow("last")'>Move Last</button>

<script type='text/javascript'>
var whichrow=false

function thisrow(x){
if (whichrow) whichrow.style.backgroundColor='transparent'
whichrow = x
whichrow.style.backgroundColor='yellow'
}

function moverow(x){
if (whichrow) {
if (x=='up'&&whichrow.previousSibling)
whichrow.parentNode.insertBefore(whichrow,
whichrow.previousSibling);
else if (x=='down'&&whichrow.nextSibling)
whichrow.parentNode.insertBefore(whichrow.nextSibl ing,
whichrow);
else if (x=='first')
whichrow.parentNode.insertBefore(whichrow,
whichrow.parentNode.firstChild);
else if (x=='last')
whichrow.parentNode.insertBefore(whichrow,null);
} else
alert("First select a row, please!");
}
</script>

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)
Dec 27 '05 #3
wmc
Thanks,I'll give that a try!

--wmc
Dec 27 '05 #4

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

Similar topics

3
4487
by: Eric | last post by:
Let me start by saying that I'm still very new at PHP/MySql and will take any advice. :-) The issues is that every once in a while users get an error when they use this code. I believe the...
6
9455
by: Stephen Miller | last post by:
Firstly, sorry for the long post, but I've included a fair bit of sample data. Im doing a comparision of 10yr Bond prices and CPI adjustments, with an 18 week moving average of the CPI. I'm...
2
1886
by: moller | last post by:
Im looking in to the possibility of moving from mySQL to an access database. My reasons are: (1) Database is single user. (2) Database local on users PC. (3) Database has only 8 tables where 4...
3
1616
by: Simon | last post by:
Hi everyone, I have a small problem regarding a wizard that I'm making on my website. The wizard is obviously a series of pages that take values from the user. My question is: - Should I...
0
1807
by: Subba Rao via DotNetMonster.com | last post by:
---------------------------HTML---------------------------------------- <html> <head> <title>:: DHTML Table Demo ::</title> <script langauge="javascript" src="InterchangeRows.js"></script>...
34
5001
by: Karam Chand | last post by:
Hello I have been working with Access and MySQL for pretty long time. Very simple and able to perform their jobs. I dont need to start a flame anymore :) I have to work with PGSQL for my...
0
1423
by: Randall Skelton | last post by:
Hi all, I have begun the slow process of shuffling data from about 125 narrow tables into a single wide table and I am seeking some insight on the 'fastest way.' The narrow tables are all of...
5
1782
by: m.e.bruche | last post by:
Hi, In my database, I created a lot of tables before I found out about schemas. It's a mess! Suppose I want to get organised, and create a couple of schemas. How do I move existing tables...
3
1626
by: Don Miller | last post by:
In my migration from ASP to ASP.NET 2.0, I have a fair number of complicated HTML tables that defy anything .NET can do. Using classic ASP I created these tables (by string concatenation) by moving...
2
3867
by: Conrad Lender | last post by:
On 2008-10-10 19:56, T.G. wrote: This doesn't work at all, at least not in Firefox. When any of the "up" or "down" links is clicked, the following error occurs: clickedRow.removeNode is not a...
0
7160
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7537
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...
1
7099
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7525
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5685
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4746
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3233
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3222
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
456
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.