Bug: Numerical sorting with dynamically added row with 0 value is incorrectly placed.
Bug: Numerical sorting with dynamically added row with 0 value is incorrectly placed.
[Deleted User]
Posts: 0Questions: 2Answers: 0
Hello,
Summary:
- Table has existing data at time of DataTable bind.
- DataTable multiple column ordering is set on a numerical column (descending) and a date/time column (descending).
- A new row is added via .row.add().
- This new row contains 0 for the numerical column and the current date/time for the other column.
- What happens: This new row with 0 for the numerical sort column appears at the BOTTOM of the table.
- Expected: It should be above existing "0" rows because even though the numerical value is identical, the secondary column sort should place the date/time value before the existing row.
Live: http://live.datatables.net/jiraviqi/1
Instructions:
- Click "Add Priority 1 Row". Observe row inserted above existing priority 1 rows.
- Click "Add Priority 0 Row". Observe row inserted BELOW existing priority 0 rows. This is wrong.
I have wrote a document explaining this better, with examples at https://www.dropbox.com/s/c67d03ri5g6t1nb/sort.pdf?dl=0
Please note that this functionality worked ok in 1.8.2 using aaSorting and fnAddData.
I have tried 1.10.0 and 1.10.2 and the fault appears in both.
Currently, we are unable to use 1.10.x because of this issue.
Thanks,
Paul
This discussion has been closed.
Answers
A friend of mine suggested the following fix:
Change the __numericReplace function as follows:
Change:
to
I tested this and it does appear to fix the problem.
Test page at: http://live.datatables.net/zefagibe/2
Can this be implemented in the next release please?
Thanks
Just a note to say Allan has responded to this over at GitHub for anyone following this.
https://github.com/DataTables/DataTables/issues/414