Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: Javascript Java HTML Ajax MySQL JSP , +
Hi all: I met a problem like this. Here is the scenario: if I have a database table A, which contains several columns, for example. Once the sever pass the database to web client, it's rendered into a HTML table. Now, here is some requirements for the client side. The user will be able to add/delete several rows from the HTML table, in addition, they will also be able the change the row order. If we could finish the client side with the help from some jquery plugin (for example: http://www.isocra.com/2007/07/dragging-and-dropping-table-rows-in-javascript/#demo[^]). Now, my question is, how could I pass this information back to server? Because there are new rows and deleted rows, the original table row order (like the plugin tableDnD.serialize function is not sufficient) is not enough. How to do this?Please let me know if anyone have idea about that.I got stuck in it since 5 days.Thanking you in advance
 
on drop this javascript function is calling.
this.onDrop = function(table, droppedRow) {
       // alert("ondrop1");
       var rows = this.table.tBodies[0].rows;
       var debugStr = "rows now: ";
       for (var i=0; i<rows.length; i++) {
           debugStr += rows[i].id+" ";
       //  alert(debugStr);
       }
   //  document.getElementById('debug').innerHTML = 'dropped<br>'+debugStr;
   }
 
now i have to send new position of row to server side.How to do this?
Posted 21-Mar-12 0:57am
Edited 26-Mar-12 2:55am
v8

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you need a mouse event for "mouseup". in that moment you can figure the new row number and work with that one.
 
http://www.w3schools.com/jsref/event_onmouseup.asp[^]
  Permalink  
Comments
jitendra BABA at 21-Mar-12 23:07pm
   
Thank you for your answer.I am using this website (http://www.isocra.com/2007/07/dragging-and-dropping-table-rows-in-javascript/#demo ) code for Dragging and droppping .It is working fine but the problem is that how to save this new row position in database.
TorstenH. at 22-Mar-12 2:27am
   
...so it is NOT about JSP, the table or the event. You just don't know how to handle a database.
 
Do you have a SQL database?
 
Here is a simple tutorial on how to store something in a database.
Insert data in mysql database through jsp using prepared statement @orseindia
jitendra BABA at 22-Mar-12 2:41am
   
I know how to insert any values or records in database but problem is that how to send new position on row(html table after dragging) to java Class(code).for this they(http://www.isocra.com/2007/07/dragging-and-dropping-table-rows-in-javascript/#demo ) are using a function
 
/** This function is called when you drop a row, so redefine it in your code
to do whatever you want, for example use Ajax to update the server */
this.onDrop = function(table, droppedRow) {

// Do nothing for now
}
 
in javascript code. So I have to sent this droppedRow id to javaCode.please share with me your views.
TorstenH. at 26-Mar-12 6:18am
   
Don't push your question.
 
You should probably address the server and tell him about your client's decision to change the row numbering. I would suggest a POST Request
jitendra BABA at 27-Mar-12 1:23am
   
@TorstenH. Thank you for given me a such good link.It is really a nice tutorial for AJAX.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Maciej Los 295
1 OriginalGriff 249
2 Sergey Alexandrovich Kryukov 205
3 Aajmot Sk 197
4 Sinisa Hajnal 176
0 OriginalGriff 7,800
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,790


Advertise | Privacy | Mobile
Web03 | 2.8.1411023.1 | Last Updated 26 Mar 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100