fix: 🐛 Sort rows numerically
Default sort method uses alphabetical sort
This commit is contained in:
parent
cfbb891737
commit
6fe075467d
14
index.html
14
index.html
@ -76,6 +76,12 @@
|
||||
]
|
||||
|
||||
data = [
|
||||
{
|
||||
'Files': 'All Folders',
|
||||
'Size': '2M',
|
||||
'Last Updated': '',
|
||||
'indent': -1
|
||||
},
|
||||
{
|
||||
'Files': 'Documents',
|
||||
'Size': '2M',
|
||||
@ -130,7 +136,15 @@
|
||||
'Last Updated': 'A few seconds ago',
|
||||
'indent': 2
|
||||
},
|
||||
{
|
||||
'Files': 'dist',
|
||||
'Size': '21k',
|
||||
'Last Updated': 'A few seconds ago',
|
||||
'indent': 2
|
||||
},
|
||||
]
|
||||
|
||||
data.map(d => d.indent++)
|
||||
}
|
||||
|
||||
function buildData() {
|
||||
|
||||
@ -4,7 +4,8 @@ import {
|
||||
nextTick,
|
||||
ensureArray,
|
||||
linkProperties,
|
||||
uniq
|
||||
uniq,
|
||||
numberSortAsc
|
||||
} from './utils';
|
||||
|
||||
export default class RowManager {
|
||||
@ -192,7 +193,7 @@ export default class RowManager {
|
||||
|
||||
const childrenToShow = this.datamanager.getImmediateChildren(rowIndex);
|
||||
const visibleRows = this.bodyRenderer.visibleRows;
|
||||
const rowsToShow = uniq([...childrenToShow, ...visibleRows]).sort();
|
||||
const rowsToShow = uniq([...childrenToShow, ...visibleRows]).sort(numberSortAsc);
|
||||
|
||||
this.showRows(rowsToShow);
|
||||
}
|
||||
@ -203,7 +204,9 @@ export default class RowManager {
|
||||
|
||||
const rowsToHide = this.datamanager.getChildren(rowIndex);
|
||||
const visibleRows = this.bodyRenderer.visibleRows;
|
||||
const rowsToShow = visibleRows.filter(rowIndex => !rowsToHide.includes(rowIndex));
|
||||
const rowsToShow = visibleRows
|
||||
.filter(rowIndex => !rowsToHide.includes(rowIndex))
|
||||
.sort(numberSortAsc);
|
||||
|
||||
rowsToHide.forEach(rowIndex => {
|
||||
const row = this.datamanager.getRow(rowIndex);
|
||||
|
||||
@ -45,7 +45,6 @@
|
||||
.dt-scrollable {
|
||||
height: 40vw;
|
||||
overflow: auto;
|
||||
border-bottom: 1px solid var(--dt-border-color);
|
||||
|
||||
&--highlight-all {
|
||||
background-color: var(--dt-selection-highlight-color);
|
||||
|
||||
@ -130,3 +130,7 @@ export function ensureArray(val) {
|
||||
export function uniq(arr) {
|
||||
return _uniq(arr);
|
||||
}
|
||||
|
||||
export function numberSortAsc(a, b) {
|
||||
return a - b;
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user