Rowreorder with unordered sequence... Part2

Rowreorder with unordered sequence... Part2

smadersmader Posts: 21Questions: 6Answers: 0

Hello,

What I would like to do is have a table which the user can order columns (asc/desc), and still retain rowreoder functionality. Various attempts at this suggest using a (perhaps) hidden column to retain a sequence. I took a look at this example[1], cloned it and produced a jsfiddle of it here[2]. Now the table works as I expect, however, if I were to loop over the table rows after reordering, I do not get the data I see on the screen for each row.

[1] https://datatables.net/forums/discussion/46889/row-reordering-after-sorting
[2] http://live.datatables.net/hifomuqa/29/edit

For example, from the jsfiddle upon loading, if I type $("#example").DataTable().row(0).data() into the console, I get:

[object Object] {
  #: 1,
  addToGeneration: "<button type='button' class='table-button' id='1'>Add</button>",
  category: "Fruits",
  description: "<button type='button' class='table-button' id='1'>Description</button>",
  name: "Apple",
  sequence: 1,
  size: "small",
  unit: "pcs"
}

However, swap Apple and Boeing, the above call returns:

[object Object] {
  #: 2,
  addToGeneration: "<button type='button' class='table-button' id='1'>Add</button>",
  category: "Fruits",
  description: "<button type='button' class='table-button' id='1'>Description</button>",
  name: "Apple",
  sequence: 2,
  size: "small",
  unit: "pcs"
}

It looks like the underlying table row/cell cache is not being updated. I tried putting rows().invalidate() in various places, but it doesn't seem to update the underlying cache.

I could add a class to each row, and use a standard jQuery selector to extract the information I want from the DOM elements, but given my existing code uses the API, is there something I'm missing?

Many thanks...
Stacy.

Answers

This discussion has been closed.