File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ class NumberFormatter {
2
2
constructor ( vm , column ) {
3
3
this . vm = vm ;
4
4
this . column = column ;
5
+ this . segments = column . name . split ( '.' ) ;
5
6
this . totals = this . hasTotal ( ) ;
6
7
}
7
8
@@ -10,9 +11,11 @@ class NumberFormatter {
10
11
}
11
12
12
13
replace ( column ) {
13
- this . vm . body . data = this . vm . body . data . map ( ( row , index ) => {
14
- row [ this . column . name ] = column [ index ] ;
15
- return row ;
14
+ const { length } = this . segments ;
15
+ this . vm . body . data . forEach ( ( row , index ) => {
16
+ this . segments . forEach ( ( segment , idx ) => idx + 1 === length
17
+ ? ( row [ segment ] = column [ index ] )
18
+ : row = row [ segment ] )
16
19
} ) ;
17
20
18
21
if ( this . totals ) {
@@ -32,7 +35,8 @@ class NumberFormatter {
32
35
}
33
36
34
37
numbers ( ) {
35
- const column = this . vm . body . data . map ( row => row [ this . column . name ] ) ;
38
+ const column = this . vm . body . data
39
+ . map ( row => this . segments . reduce ( ( row , segment ) => row [ segment ] , row ) ) ;
36
40
37
41
if ( this . totals ) {
38
42
column . push ( this . vm . body . total [ this . column . name ] ) ;
You can’t perform that action at this time.
0 commit comments