File tree Expand file tree Collapse file tree 2 files changed +11
-1
lines changed
containers/Tenant/Preview Expand file tree Collapse file tree 2 files changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ import Fullscreen from '../../../components/Fullscreen/Fullscreen';
1212import { sendQuery , setQueryOptions } from '../../../store/reducers/preview' ;
1313import { showTooltip , hideTooltip } from '../../../store/reducers/tooltip' ;
1414import { prepareQueryError , prepareQueryResponse } from '../../../utils/index' ;
15+ import { isNumeric } from '../../../utils/utils' ;
1516
1617import { isTableType } from '../utils/schema' ;
1718import { AutoFetcher } from '../../../utils/autofetcher' ;
@@ -127,6 +128,8 @@ class Preview extends React.Component {
127128 if ( data && data . length > 0 ) {
128129 columns = Object . keys ( data [ 0 ] ) . map ( ( key ) => ( {
129130 name : key ,
131+ align : isNumeric ( data [ 0 ] [ key ] ) ? DataTable . RIGHT : DataTable . LEFT ,
132+ sortAccessor : ( row ) => isNumeric ( row [ key ] ) ? Number ( row [ key ] ) : row [ key ] ,
130133 render : ( { value} ) => {
131134 return (
132135 < span
Original file line number Diff line number Diff line change @@ -81,4 +81,11 @@ export function pad9(val) {
8181 result = "0" + result ;
8282 }
8383 return result ;
84- }
84+ }
85+
86+ export function isNumeric ( value ) {
87+ // need both isNaN and isNaN(parseFloat):
88+ // - isNaN treats true/false/''/etc. as numbers, parseFloat fixes this
89+ // - parseFloat treats '123qwe' as number, isNaN fixes this
90+ return ! isNaN ( value ) && ! isNaN ( parseFloat ( value ) ) ;
91+ } ;
You can’t perform that action at this time.
0 commit comments