forked from TFMM/silent-auction
fix: re-implement numeric natural sorting for dropdowns
This commit is contained in:
@@ -19,12 +19,17 @@
|
|||||||
dropdownParent: 'body',
|
dropdownParent: 'body',
|
||||||
controlInput: '<input>',
|
controlInput: '<input>',
|
||||||
sortField: [{
|
sortField: [{
|
||||||
field: '$text',
|
field: 'text',
|
||||||
direction: 'asc'
|
direction: 'asc'
|
||||||
}],
|
}],
|
||||||
render: {
|
// Natural sort plugin or custom sorter:
|
||||||
option: function(item, escape) {
|
// We use a custom sort function to handle the "1 - ..." format
|
||||||
return '<div>' + escape(item.text) + '</div>';
|
// This ensures "1" < "2" < "10"
|
||||||
|
sortField: {
|
||||||
|
field: 'text',
|
||||||
|
direction: 'asc',
|
||||||
|
func: function(a, b) {
|
||||||
|
return a.text.localeCompare(b.text, undefined, {numeric: true, sensitivity: 'base'});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user