Row reorder doesn't work with "pre-built" HTML table, but works when rows are added using row.add
Row reorder doesn't work with "pre-built" HTML table, but works when rows are added using row.add
See here: https://c9pets.erpecommerce.com/express/
When rows are added using row.add reorder works. For example add items TOYRED, TOYBLUE and CRATEWIRE. You can drag the rows and they reorder. I have a debug alert that shows what happened.
When runing datatables on an HTML table that is pre populated, reordering doesn't work. To see this log in (Allan - I set up a used for you using your e-mail address, password is password), and go here: https://c9pets.erpecommerce.com/express/purchasehistory/
This creates a populated table in HTML before running datatables. Note that positions, etc do not work when reordering. Using inspect in Chrome, when dragging the row you can see the <tr> elements move.
Confused.
This question has an accepted answers - jump to answer
Answers
The default data source for row reorder (
rowReorder.dataSrc
) is0
(i.e. array index 0). That works in your first table since that column does contain the index order. However, in the second example it isn't (I think its column index 3 that contains the index - but not 100% certain). So you need to tell RowReorder which column contains the index.Allan
Interestingly, when I set the dataSrc to column 3, that stopped the first example from working for some reason, but it got me going in the right direction.
I found that populating the sequence <tr> when generating the table fixed the issue, based on the rowReorder examples.
Thanks.