Editor with RowReorder doesn't post ajax request if idSrc is other than DT_RowId
Editor with RowReorder doesn't post ajax request if idSrc is other than DT_RowId
Link to test case:
http://live.datatables.net/dozifure/28/edit
Description of problem:
See the test case. As written, it allows re-ordering of rows, which calls the ajax function.
However, if you change the first line to
var idKey = 'id';
(which sets the idSrc
of the editor instance to "id"
rather than "DT_RowId"
)
then it no longer works: when you drag rows to reorder, the ajax function is never called, and the order column is not updated in the UI.
My data source doesn't have a field DT_RowId
, and I'd rather not have to create/assign one. Am I doing something wrong here, or is this a bug?
Replies
Thanks for the excellent example! Although the
idSrc
docs seem to indicate otherwise it looks like you need to set the Datatables optionrowId
, for example:http://live.datatables.net/tovuwubu/1/edit
@allan will need to comment on whether needing
rowId
is expected for this case.Kevin
That did the trick. Thanks so much @kthorngren!
Just to re-raise this issue. This was also my problem but couldn't find anything related to
rowReorder
and requiring it requiringrowId
in the .Net examples or documentation.I simply use a different key than "id", Editor worked with
idSrc
being set just fine till I implementedrowReorder
.Apologies - I missed this thread at the time. Typically Editor's
idSrc
and DataTables'rowId
should be set to the same value. If you are using the provided server-side libraries for .NET, PHP or Node.js then it will just automatically work since they useDT_RowId
for the primary key identifier (even if you tell them to read from a column other thanid
as the name in the database). If your data doesn't have that property, then yes, you should set both of them.Allan