javascript - jquery DataTables row reordering: order reverts back after drop -


i trying use jquery datatables (http://datatables.net/) row ordering plugin (http://code.google.com/p/jquery-datatables-row-reordering/wiki/index). originally, re-ordering of rows looked worked, there javascript error "error: syntax error, unrecognized expression: #". implemented solution outlined here: http://datatables.net/forums/discussion/19011/drag-and-drop-row-reordering-issue giving tr elements unique ids. there no javascript errors. however, row re-ordering doesn't work @ now. drag row, when drop it, table reverts previous state.

here's full html file javascript: http://pastebin.com/2p9hj7n2

has else encountered problem? if so, how have solved it?

i tried digging around in row reordering javascript , looks problem grabbing current , previous position of row:

// fyi: properties.iindexcolumn 0 var icurrentposition = otable.fngetdata(tr, properties.iindexcolumn); //... otable.fngetdata(trprevious[0], properties.iindexcolumn); 

whatever it's expecting fngetdata has changed. i've iterated on otable.fngetdata(tr, i) returns couple of values of , seems cells of row.

my guess implementation of datatables has changed since plugin written. i'm wondering if it's possoble fix or not.

as can read in wiki-link provided,

  • each tr element must have id attribute.
  • one column in table should indexing column. column used determining position of row in table. default first column in table. can see structure of table on live example page.

the "unrecognized expression: #" related first demand; not able move rows around related second. lack indexing column. have figured out missing <tr> #id, can create column programmatically :

$("#mysupertable thead tr").prepend('<th>#</td>');     var count = $("#mysupertable tbody tr").length-1; $("#mysupertable tbody tr").each(function(i, tr) {     $(tr).attr('id', 'id'+i);     $(tr).prepend('<td>'+parseint(i+1)+'</td>');         if (i==count) {        $("#mysupertable").datatable({            //...initialization options        }).rowreordering();     }      });   

now rowreordering works table -> http://jsfiddle.net/gy8s3hoa/

notice demo above running datatables 1.10.x. issue has nothing datatables versions or changes in datatables internals, how rowreordering plugin created. not elegant, if ask me. plugin should create id's , index column needing (and make hidden) itself.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -