File tree 5 files changed +35
-12
lines changed
5 files changed +35
-12
lines changed Original file line number Diff line number Diff line change @@ -42,6 +42,11 @@ export namespace Transform {
42
42
*/
43
43
type : 'hide' ;
44
44
45
+ /**
46
+ * The column in the data schema to apply the transformation to.
47
+ */
48
+ column : string ;
49
+
45
50
/**
46
51
* The column in the data schema to apply the transformation to.
47
52
*/
Original file line number Diff line number Diff line change @@ -64,6 +64,11 @@ export namespace HideExecutor {
64
64
*/
65
65
field : string ;
66
66
67
+ /**
68
+ * The data type of the column associated with this transform.
69
+ */
70
+ dType : string ;
71
+
67
72
/**
68
73
* Boolean indicating if all columns should be hidden
69
74
*/
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ export class TransformStateManager {
44
44
this . _state [ transform . column ] [ 'filter' ] = transform ;
45
45
break ;
46
46
case 'hide' :
47
- this . _state [ transform . columnIndex ] [ 'hide' ] = transform ;
47
+ this . _state [ transform . column ] [ 'hide' ] = transform ;
48
48
break ;
49
49
default :
50
50
throw 'unreachable' ;
@@ -153,8 +153,16 @@ export class TransformStateManager {
153
153
filterExecutors . push ( executor ) ;
154
154
}
155
155
if ( transform . hide ) {
156
+ let dType = '' ;
157
+ for ( const field of data . schema . fields ) {
158
+ if ( field . name === transform . hide . column ) {
159
+ dType = field . type ;
160
+ }
161
+ }
162
+
156
163
const executor = new HideExecutor ( {
157
- field : data . schema . fields [ transform . hide . columnIndex ] [ 'name' ] ,
164
+ field : transform . hide . column ,
165
+ dType,
158
166
hideAll : transform . hide . hideAll ,
159
167
} ) ;
160
168
hideExecutors . push ( executor ) ;
Original file line number Diff line number Diff line change @@ -76,7 +76,6 @@ export class ViewBasedJSONModel extends MutableDataModel {
76
76
*/
77
77
updateDataset ( data : DataSource ) : void {
78
78
this . _dataset = data ;
79
- // does not happen when selecting hide column
80
79
this . _updatePrimaryKeyMap ( ) ;
81
80
const view = new View ( this . _dataset ) ;
82
81
this . currentView = view ;
@@ -567,7 +566,6 @@ export class ViewBasedJSONModel extends MutableDataModel {
567
566
}
568
567
// We need to rerun the transforms, as the changed cells may change the order
569
568
// or visibility of other rows
570
- console . log ( 'update row value' ) ;
571
569
this . currentView = this . _transformState . createView ( this . _dataset ) ;
572
570
}
573
571
Original file line number Diff line number Diff line change @@ -1074,14 +1074,20 @@ export class FeatherGrid extends Widget {
1074
1074
label : 'Hide Column' ,
1075
1075
mnemonic : - 1 ,
1076
1076
execute : ( args ) => {
1077
- const cellClick : FeatherGridContextMenu . CommandArgs =
1077
+ const command : FeatherGridContextMenu . CommandArgs =
1078
1078
args as FeatherGridContextMenu . CommandArgs ;
1079
+
1079
1080
const colIndex = this . _dataModel . getSchemaIndex (
1080
- cellClick . region ,
1081
- cellClick . columnIndex ,
1081
+ command . region ,
1082
+ command . columnIndex ,
1082
1083
) ;
1084
+
1085
+ const column =
1086
+ this . dataModel . currentView . dataset . schema . fields [ colIndex ] ;
1087
+
1083
1088
this . _dataModel . addTransform ( {
1084
1089
type : 'hide' ,
1090
+ column : column . name ,
1085
1091
columnIndex : colIndex ,
1086
1092
hideAll : false ,
1087
1093
} ) ;
@@ -1097,8 +1103,13 @@ export class FeatherGrid extends Widget {
1097
1103
cellClick . region ,
1098
1104
cellClick . columnIndex ,
1099
1105
) ;
1106
+
1107
+ const column =
1108
+ this . dataModel . currentView . dataset . schema . fields [ colIndex ] ;
1109
+
1100
1110
this . _dataModel . addTransform ( {
1101
1111
type : 'hide' ,
1112
+ column : column . name ,
1102
1113
columnIndex : colIndex ,
1103
1114
hideAll : true ,
1104
1115
} ) ;
@@ -1110,14 +1121,10 @@ export class FeatherGrid extends Widget {
1110
1121
execute : ( ) => {
1111
1122
const activeTransforms : Transform . TransformSpec [ ] =
1112
1123
this . _dataModel . activeTransforms ;
1113
- console . log (
1114
- 'this._dataModel.activeTransforms' ,
1115
- this . _dataModel . activeTransforms ,
1116
- ) ;
1124
+
1117
1125
const newTransforms = activeTransforms . filter (
1118
1126
( val ) => val . type !== 'hide' ,
1119
1127
) ;
1120
- console . log ( 'newTransforms' , newTransforms ) ;
1121
1128
this . _dataModel . replaceTransforms ( newTransforms ) ;
1122
1129
} ,
1123
1130
} ) ;
You can’t perform that action at this time.
0 commit comments