mpryvkin / jquery-datatables-row-reordering

JQuery plugin that enables drag and drop row reordering in the tables enhanced with JQuery DataTables plugin.
https://www.gyrocode.com/articles/jquery-datatables-row-reordering/
6 stars 8 forks source link

Feature Request - callback function before ajax update #8

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I am setting the sURL property to make a server call when the rows are 
reordered.  This is working as expected.  However, my requirements demand that 
all ajax calls contain a security token.  Would it be possible to add a 
callback function that executes immediately before the ajax call?  Ideally, the 
args for this function would be the json object:
{ id: ui.item.context.id,
  fromPosition: oState.iCurrentPosition,
  toPosition: oState.iNewPosition,
  direction: oState.sDirection,
  group: sGroup
}
currently used by the ajax call, so I could append my security token to it.

I could understand that you may not want to expose this data, so another option 
could be to pass the callback function an empty json object (or maybe it could 
at least contain the row Id) to be manipulated, then you could add the 
to/fromPosition and other data after the callback executes.

Thanks

Original issue reported on code.google.com by eng...@gmail.com on 2 Aug 2012 at 3:59

GoogleCodeExporter commented 9 years ago
I have the same need. I added one line to the code (line 217): sid : 
properties.sSID
so the data object passed to the ajax call now reads:
                            data: { id: ui.item.context.id,
                                fromPosition: oState.iCurrentPosition,
                                toPosition: oState.iNewPosition,
                                direction: oState.sDirection,
                                group: sGroup,
                                sid : properties.sSID
                            },

To use it, I add sSID to the options object when I apply the plug-in
$dt.rowReordering({sURL: 'somecode.php', sSID: 'ABCD4321'});

Original comment by psm...@gmail.com on 26 Nov 2012 at 9:10

GoogleCodeExporter commented 9 years ago

Original comment by joc...@gmail.com on 27 May 2013 at 9:29

GoogleCodeExporter commented 9 years ago
Hi,

See 
http://jquery-datatables-row-reordering.googlecode.com/svn/trunk/Issue8.html - 
now you can pass function that modifies Ajax request:

"fnUpdateAjaxRequest": function(oAjaxRequest, oProperties, $dataTable){
                oAjaxRequest.data.SECURITY_TOKEN=123456789;
            }

Jovan

Original comment by joc...@gmail.com on 6 Jun 2013 at 2:28

GoogleCodeExporter commented 9 years ago
This is almost what I'm looking for.
I'm working with Backbonejs and I'd like to update my model first, like this:

this.myDataTable.rowReordering({
 url: updateFunction
});

updateFunction: function(data){
//update model with new data
}

Is this possible?
Thanks.

Original comment by maxime.v...@gmail.com on 10 Jun 2013 at 1:25