Drag n Drop row reordering on new rows
Drag n Drop row reordering on new rows

Hey guys, im using a third party plugin to reorder rows in a DataTables table, I found it here: http://jquery-datatables-row-reordering.googlecode.com/svn/trunk/index.html
I got it working after some tweaking, heres the JS code for it so far:
var t = $attributes_table.dataTable( {
"bPaginate": false,
"bFilter": false,
"bSort": false,
"fnRowCallback": function ( nRow, aData, iDisplayIndex, iDisplayIndexFull ) {
$(nRow).attr( 'data-row-id', iDisplayIndex);
$(nRow).attr( 'id', aData.RowOrder);
$(nRow).find('.attr-setting-order' ).val(iDisplayIndex);
}
}).rowReordering();
It seems to work OK on existing rows, but when i add new rows using the fnAddData(), it wont let me reorder those rows. No errors are displayed in the console, it just doesnt reorder the row at all.
When I add rows to a table with existing rows, it will drag the new rows, but wont change the order number value, but then when I drag an OLD row, it will reorder it fine, and put the last row (the new row), back at the bottom (or wherever it was).
Kidna stuck on this one, any help would be great. Thanks!
This question has accepted answers - jump to:
Answers
Actually, when I drag a NEW row, I get the error in the console:
Uncaught Error: Syntax error, unrecognized expression: #
I don't have any experience with that plug-in, so I'm afraid you would need to debug the issue - at a guess it sounds like an issue with the id or perhaps the plug-in has some kind of cache.
On the plus side, I'm going to be releasing a row reordering plug-in as part of the DataTables project (i.e. it will be officially supported) soon. It should be available by the end of the month.
Allan
Oh awesome, looks like ill be waiting!
Off topic, but how about a new version of the fixed header plugin? https://legacy.datatables.net/release-datatables/extras/FixedHeader/top_bottom_left_right.html
I need something like that, but i know thats legacy. is it bad to use legacy plugins? will they work with the new version of DT?
FixedHeader is not legacy. The specific example you linked to is - but FixedHeader most certainly is not.
Allan
@Allan - When will this plugin be ready?
Targeting a release next week.
Allan
Thanks!
Allan, was this ever completed? I havent seen it anywhere, maybe im looking in the wrong area
The software is complete, but not yet released. Writing up the documentation for all the new software I've been working on is taking longer than expected! It will be available very soon (likely Monday).
Allan
Awesome! Thank you
Allan, any update? :-D
Wednesday :-)
I'm going to stop announcing software! I reckon half the threads in the forum are about the up coming releases at the moment :-)
Allan
Why not have actual realistic release dates listed somewhere? with updates?...
.. What other updates are coming out? lol
P.S. I did ask where I can look to see it when its released, so I dont keep bugging you :P
No worries :-). It will be announced in the blog.
Other new extensions: Buttons and Select (replacing TableTools and ColVis). Rewrites: KeyTable and AutoFill. Editor 1.5 with multi-row editing. And all the other remaining extensions are getting updates. Lots of software tomorrow.
Haha. Back in May, I realistically thought it would be done by the end of June ;-)
Allan
Oh... so it might not even be done tomorrow?
Lmk, because then I need to find another way to do this soon...
It will be done tomorrow. The software and documentation are all done. Web-site infrastructure for it is mostly ready. I'm tagging modules at the moment. I've then got a bit more infrastructure to update and then to deploy. It will take a good few hours of work tomorrow (possibly a late night, although i hope not given how late it already is tonight :-) ), but it will be done. I'm gutted that it has taken this long already, but hopefully it will be worth the wait.
Allan
"already tonight"? Where are you located at?
Allan.. Question about the new plugin you're making, lol.
I plan on using the Row Grouping plugin (http://datatables.net/examples/advanced_init/row_grouping.html), so I was wondering, is it possible to..
1) Dynamically create/delete rows
2) Re-order row into the new groups, as well as re-order the groups themselves?
If I can just insert a new TR into the table with a custom colspan on the TD, and refresh the table, then that will work just fine for question numero dos
Thansks!
I'm in the UK - just north of Edinburgh :-)
Yes. DataTables core has
row.add()
androw().remove()
. That is not related to the new plug-in.Probably not. You can reorder individual rows, which swaps the data for the moved rows. So if you move row 5 into position 1, it takes row 1's data, 2 takes 3's, etc. There is currently no option to just change a single value. Sounds like a good idea for a future enhancement.
Also since it is individual row reordering, a whole group cannot be reordered. Sorry.
Allan
Ok, In my app, you can create "attributes" (rows in the table) and group the attributes into groups, so im trying to find a way to both automatically re-order the rows to display the rows within the groups, but also allow them to re-order the groups
Hey Allan, I dont see it in the blog?
Link.
This is the full documentation for RowReorder.
It might not be massively useful for your case though, since it uses data swap as I noted above, rather than a direct assignment into a group at the moment.
Allan
I think this will work for now. Ill come up with a way to do the grouping some other way, haha