@@ -65,7 +65,7 @@ class DataTables extends Component {
65
65
title : i . label ,
66
66
data : i . label ,
67
67
type : type ,
68
- render : this . dataRenderer ( data , type , index )
68
+ render : this . dataRenderer ( type , index )
69
69
} ;
70
70
} ) ;
71
71
@@ -94,9 +94,9 @@ class DataTables extends Component {
94
94
pagingType : settings . pagingType ,
95
95
ordering : 'false' === settings . ordering_bool ? false : true ,
96
96
fixedHeader : 'true' === settings . fixedHeader_bool ? true : false ,
97
- scrollCollapse : this . props . chartsScreen && true || 'true' === settings . scrollCollapse_bool ? true : false ,
97
+ scrollCollapse : ! ! this . props . chartsScreen || 'true' === settings . scrollCollapse_bool ? true : false ,
98
98
scrollY : this . props . chartsScreen && 180 || ( 'true' === settings . scrollCollapse_bool && Number ( settings . scrollY_int ) || false ) ,
99
- responsive : this . props . chartsScreen && true || 'true' === settings . responsive_bool ? true : false ,
99
+ responsive : ! ! this . props . chartsScreen || 'true' === settings . responsive_bool ? true : false ,
100
100
searching : false ,
101
101
select : false ,
102
102
lengthChange : false ,
@@ -105,48 +105,47 @@ class DataTables extends Component {
105
105
} ) ;
106
106
}
107
107
108
- dataRenderer ( data , type , index ) {
108
+ dataRenderer ( type , index ) {
109
109
const settings = this . props . options ;
110
110
111
- if ( undefined === settings . series [ index ] ) {
112
- return data ;
113
- }
114
-
115
- if ( 'date' === type || 'datetime' === type || 'timeofday' === type ) {
116
- if ( settings . series [ index ] . format && settings . series [ index ] . format . from && settings . series [ index ] . format . to ) {
117
- return jQuery . fn . dataTable . render . moment ( settings . series [ index ] . format . from , settings . series [ index ] . format . to ) ;
118
- }
119
-
120
- return jQuery . fn . dataTable . render . moment ( 'MM-DD-YYYY' ) ;
121
- }
122
-
123
- if ( 'num' === type ) {
124
- const parts = [ '' , '' , '' , '' , '' ] ;
125
-
126
- if ( settings . series [ index ] . format . thousands ) {
127
- parts [ 0 ] = settings . series [ index ] . format . thousands ;
128
- }
129
-
130
- if ( settings . series [ index ] . format . decimal ) {
131
- parts [ 1 ] = settings . series [ index ] . format . decimal ;
132
- }
133
-
134
- if ( settings . series [ index ] . format . precision ) {
135
- parts [ 2 ] = settings . series [ index ] . format . precision ;
136
- }
137
-
138
- if ( settings . series [ index ] . format . prefix ) {
139
- parts [ 3 ] = settings . series [ index ] . format . prefix ;
140
- }
141
-
142
- if ( settings . series [ index ] . format . suffix ) {
143
- parts [ 4 ] = settings . series [ index ] . format . suffix ;
144
- }
111
+ let renderer = null ;
112
+ if ( 'undefined' === typeof settings . series [ index ] || 'undefined' === typeof settings . series [ index ] . format ) {
113
+ return renderer ;
114
+ }
115
+
116
+ switch ( type ) {
117
+ case 'date' :
118
+ case 'datetime' :
119
+ case 'timeofday' :
120
+ if ( settings . series [ index ] . format && settings . series [ index ] . format . from && settings . series [ index ] . format . to ) {
121
+ renderer = jQuery . fn . dataTable . render . moment ( settings . series [ index ] . format . from , settings . series [ index ] . format . to ) ;
122
+ } else {
123
+ renderer = jQuery . fn . dataTable . render . moment ( 'MM-DD-YYYY' ) ;
124
+ }
125
+ break ;
126
+ case 'num' :
127
+ const parts = [ '' , '' , '' , '' , '' ] ;
145
128
146
- return jQuery . fn . dataTable . render . number ( ...parts ) ;
147
- }
129
+ if ( settings . series [ index ] . format . thousands ) {
130
+ parts [ 0 ] = settings . series [ index ] . format . thousands ;
131
+ }
132
+ if ( settings . series [ index ] . format . decimal ) {
133
+ parts [ 1 ] = settings . series [ index ] . format . decimal ;
134
+ }
135
+ if ( settings . series [ index ] . format . precision && '0' != settings . series [ index ] . format . precision ) {
136
+ parts [ 2 ] = settings . series [ index ] . format . precision ;
137
+ }
138
+ if ( settings . series [ index ] . format . prefix ) {
139
+ parts [ 3 ] = settings . series [ index ] . format . prefix ;
140
+ }
141
+ if ( settings . series [ index ] . format . suffix ) {
142
+ parts [ 4 ] = settings . series [ index ] . format . suffix ;
143
+ }
144
+ renderer = jQuery . fn . dataTable . render . number ( ...parts ) ;
145
+ break ;
146
+ }
148
147
149
- return data ;
148
+ return renderer ;
150
149
}
151
150
152
151
render ( ) {
0 commit comments