CodePaste Logo
New Snippet New Snippet Recent Snippets Recent Snippets My Snippets My Snippets Web Code Search Snippets Search
Sign inor Register
Language: JavaScript

Table Drag and Drop JQuery plugin - TableDnD plugin used for jqGrid

552 Views
Copy Code Show/Hide Line Numbers
   1:  $(document).ready(function() {
   2:   
   3:      // Initialise the first table (as before)
   4:      $("#table-1").tableDnD();
   5:   
   6:      // Make a nice striped effect on the table
   7:      $("#table-2 tr:even').addClass('alt')");
   8:   
   9:      // Initialise the second table specifying a dragClass and an onDrop function that will display an alert
  10:      $("#table-2").tableDnD({
  11:          onDragClass: "myDragClass",
  12:          onDrop: function(table, row) {
  13:              var rows = table.tBodies[0].rows;
  14:              var debugStr = "Row dropped was "+row.id+". New order: ";
  15:              for (var i=0; i<rows.length; i++) {
  16:                  debugStr += rows[i].id+" ";
  17:              }
  18:              $(#debugArea).html(debugStr);
  19:          },
  20:          onDragStart: function(table, row) {
  21:              $(#debugArea).html("Started dragging row "+row.id);
  22:          }
  23:      });
  24:  });
by ZStyle
  August 24, 2010 @ 11:09pm
Tags:
Description:
http://www.isocra.com/2008/02/table-drag-and-drop-jquery-plugin/

Add a comment


Report Abuse
brought to you by:
West Wind Techologies



If you find this site useful and use it frequently please consider making a donation to support this free service.
Donate