Drag n Drop row reordering on new rows

Drag n Drop row reordering on new rows

jLinuxjLinux Posts: 981Questions: 73Answers: 75

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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Actually, when I drag a NEW row, I get the error in the console:
    Uncaught Error: Syntax error, unrecognized expression: #

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    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?

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin
    Answer ✓

    FixedHeader is not legacy. The specific example you linked to is - but FixedHeader most certainly is not.

    Allan

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    @Allan - When will this plugin be ready?

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    Targeting a release next week.

    Allan

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Thanks!

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Allan, was this ever completed? I havent seen it anywhere, maybe im looking in the wrong area

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Awesome! Thank you

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Allan, any update? :-D

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited August 2015

    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

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    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.

    actual realistic release dates

    Haha. Back in May, I realistically thought it would be done by the end of June ;-)

    Allan

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Oh... so it might not even be done tomorrow?

    Lmk, because then I need to find another way to do this soon...

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    "already tonight"? Where are you located at?

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75
    edited August 2015

    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!

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin

    I'm in the UK - just north of Edinburgh :-)

    1) Dynamically create/delete rows

    Yes. DataTables core has row.add() and row().remove(). That is not related to the new plug-in.

    2) Re-order row into the new groups, as well as re-order the groups themselves?

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    Hey Allan, I dont see it in the blog?

  • allanallan Posts: 64,032Questions: 1Answers: 10,555 Site admin
    Answer ✓

    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

  • jLinuxjLinux Posts: 981Questions: 73Answers: 75

    I think this will work for now. Ill come up with a way to do the grouping some other way, haha

This discussion has been closed.