frappe / datatable

The Missing Javascript Datatable for the Web
https://frappe.io/datatable
MIT License
1.02k stars 164 forks source link

[bug] sorting on a column is broken if some of the cells are `undefined` #81

Closed igrekus closed 5 years ago

igrekus commented 5 years ago

Undefined cell breaks the whole column into sorted sequences:

Descending: image

Ascending: image

Highlighted cell is undefined in the sample data array:

data = [
    ["Tiger Nixon", { content: "System Architect<br>New line", editable: false }, "Edinburgh", 1, "2011/04/25", 320800],
    ["Garrett Winters", "Accountant", "Tokyo", 2, "2011/07/25", 170750],
    ["Ashton Cox", "Junior Technical Author", "San Francisco", 3, "2009/01/12", 86000],
    ["Cedric Kelly", "Senior Javascript Developer", "Edinburgh", undefined, "2012/03/29", 433060],
    ["Airi Satou", "Accountant", "Tokyo", 8, "2008/11/28", 162700],
    ["Brielle Williamson", "Integration Specialist", "New York", 5, "2012/12/02", 372000],
    ["Herrod Chandler", "Sales Assistant", "San Francisco", '', "2012/08/06", 137500]
];

If the 'empty' cell is represented with an emptystring, sorting works correctly.

This is an issue when Datatable is used in the reports infrastructure within Frappe since all of the NULL values in the database are undefined in the table data.

igrekus commented 5 years ago

Closing, fixed in 4cfd0be20629c480a495e257ff2ebff9053d42fe