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

aaron.dunigan.atleeaaron.dunigan.atlee Posts: 20Questions: 7Answers: 0

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

  • kthorngrenkthorngren Posts: 21,315Questions: 26Answers: 4,948

    Thanks for the excellent example! Although the idSrc docs seem to indicate otherwise it looks like you need to set the Datatables option rowId, for example:
    http://live.datatables.net/tovuwubu/1/edit

    @allan will need to comment on whether needing rowId is expected for this case.

    Kevin

  • aaron.dunigan.atleeaaron.dunigan.atlee Posts: 20Questions: 7Answers: 0

    That did the trick. Thanks so much @kthorngren!

  • wadeparallonwadeparallon Posts: 59Questions: 9Answers: 0

    Just to re-raise this issue. This was also my problem but couldn't find anything related to rowReorder and requiring it requiring rowId in the .Net examples or documentation.

    I simply use a different key than "id", Editor worked with idSrc being set just fine till I implemented rowReorder.

  • allanallan Posts: 63,489Questions: 1Answers: 10,470 Site admin

    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 use DT_RowId for the primary key identifier (even if you tell them to read from a column other than id as the name in the database). If your data doesn't have that property, then yes, you should set both of them.

    Allan

Sign In or Register to comment.