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