@@ -23,6 +23,8 @@ export class SliderFilter implements Filter {
23
23
private _elementRangeInputId : string ;
24
24
private _elementRangeOutputId : string ;
25
25
private $filterElm : any ;
26
+ private $filterInputElm : any ;
27
+ private $filterNumberElm : any ;
26
28
grid : any ;
27
29
searchTerms : SearchTerm [ ] ;
28
30
columnDef : Column ;
@@ -86,7 +88,7 @@ export class SliderFilter implements Filter {
86
88
87
89
// step 3, subscribe to the change event and run the callback when that happens
88
90
// also add/remove "filled" class for styling purposes
89
- this . $filterElm . change ( ( e : any ) => {
91
+ this . $filterInputElm . change ( ( e : any ) => {
90
92
const value = e && e . target && e . target . value ;
91
93
this . _currentValue = + value ;
92
94
@@ -105,7 +107,7 @@ export class SliderFilter implements Filter {
105
107
// if user chose to display the slider number on the right side, then update it every time it changes
106
108
// we need to use both "input" and "change" event to be all cross-browser
107
109
if ( ! this . filterParams . hideSliderNumber ) {
108
- this . $filterElm . on ( 'input change' , ( e : { target : HTMLInputElement } ) => {
110
+ this . $filterInputElm . on ( 'input change' , ( e : { target : HTMLInputElement } ) => {
109
111
const value = e && e . target && e . target . value ;
110
112
if ( value !== undefined && value !== null ) {
111
113
const elements = document . getElementsByClassName ( this . _elementRangeOutputId ) ;
@@ -127,19 +129,18 @@ export class SliderFilter implements Filter {
127
129
this . searchTerms = [ ] ;
128
130
const clearedValue = this . filterParams . hasOwnProperty ( 'sliderStartValue' ) ? this . filterParams . sliderStartValue : DEFAULT_MIN_VALUE ;
129
131
this . _currentValue = + clearedValue ;
130
- this . $filterElm . children ( 'input' ) . val ( clearedValue ) ;
131
- this . $filterElm . children ( 'div.input-group-addon.input-group-append' ) . children ( ) . html ( clearedValue ) ;
132
- this . $filterElm . val ( clearedValue ) ;
133
- this . $filterElm . trigger ( 'change' ) ;
132
+ this . $filterInputElm . val ( clearedValue ) ;
133
+ this . $filterNumberElm . html ( clearedValue ) ;
134
+ this . $filterInputElm . trigger ( 'change' ) ;
134
135
}
135
136
}
136
137
137
138
/**
138
139
* destroy the filter
139
140
*/
140
141
destroy ( ) {
141
- if ( this . $filterElm ) {
142
- this . $filterElm . off ( 'change' ) . remove ( ) ;
142
+ if ( this . $filterInputElm ) {
143
+ this . $filterInputElm . off ( 'change' ) . remove ( ) ;
143
144
}
144
145
}
145
146
@@ -154,10 +155,11 @@ export class SliderFilter implements Filter {
154
155
/** Set value(s) on the DOM element */
155
156
setValues ( values : SearchTerm | SearchTerm [ ] , operator ?: OperatorType | OperatorString ) {
156
157
if ( Array . isArray ( values ) ) {
157
- this . $filterElm . val ( values [ 0 ] ) ;
158
+ this . $filterInputElm . val ( `${ values [ 0 ] } ` ) ;
159
+ this . $filterNumberElm . html ( `${ values [ 0 ] } ` ) ;
158
160
this . _currentValue = + values [ 0 ] ;
159
161
} else if ( values ) {
160
- this . $filterElm . val ( values ) ;
162
+ this . $filterInputElm . val ( values ) ;
161
163
this . _currentValue = + values ;
162
164
}
163
165
@@ -207,10 +209,10 @@ export class SliderFilter implements Filter {
207
209
* @param searchTerm optional preset search terms
208
210
*/
209
211
private createDomElement ( filterTemplate : string , searchTerm ?: SearchTerm ) {
210
- const fieldId = this . columnDef && this . columnDef . id ;
212
+ const columnId = this . columnDef && this . columnDef . id ;
211
213
const minValue = this . filterProperties . hasOwnProperty ( 'minValue' ) ? this . filterProperties . minValue : DEFAULT_MIN_VALUE ;
212
214
const startValue = this . filterParams . hasOwnProperty ( 'sliderStartValue' ) ? this . filterParams . sliderStartValue : minValue ;
213
- const $headerElm = this . grid . getHeaderRowColumn ( fieldId ) ;
215
+ const $headerElm = this . grid . getHeaderRowColumn ( columnId ) ;
214
216
$ ( $headerElm ) . empty ( ) ;
215
217
216
218
// create the DOM element & add an ID and filter class
@@ -224,9 +226,11 @@ export class SliderFilter implements Filter {
224
226
}
225
227
this . _currentValue = + searchTermInput ;
226
228
227
- $filterElm . children ( 'input' ) . val ( searchTermInput ) ;
228
- $filterElm . children ( 'div.input-group-addon.input-group-append' ) . children ( ) . html ( searchTermInput ) ;
229
- $filterElm . data ( 'columnId' , fieldId ) ;
229
+ this . $filterInputElm = $filterElm . children ( 'input' ) ;
230
+ this . $filterNumberElm = $filterElm . children ( 'div.input-group-addon.input-group-append' ) . children ( ) ;
231
+ this . $filterInputElm . val ( searchTermInput ) ;
232
+ this . $filterNumberElm . html ( searchTermInput ) ;
233
+ $filterElm . data ( 'columnId' , columnId ) ;
230
234
231
235
// if there's a search term, we will add the "filled" class for styling purposes
232
236
if ( searchTerm ) {
0 commit comments