@@ -134,6 +134,9 @@ export default class Datatable extends LightningElement {
134
134
@api rowActionButtonIconPosition ;
135
135
@api rowActionButtonVariant ;
136
136
137
+ // v4.3.6 Fix for not clearing removed rows after last one is removed
138
+ haveProcessedReactivity = false ;
139
+
137
140
@api
138
141
get outputActionedRow ( ) {
139
142
return this . _outputActionedRow ;
@@ -155,6 +158,10 @@ export default class Datatable extends LightningElement {
155
158
156
159
rowActionColNum ;
157
160
161
+ get rowActionColumnOffset ( ) { // v4.3.6 - for selecting correct filter column when action is on the left
162
+ return ( this . hasRowAction && this . rowActionLeftOrRight == "Left" ) ? 1 : 0 ;
163
+ }
164
+
158
165
@api
159
166
get isRemoveRowAction ( ) {
160
167
return ( this . cb_isRemoveRowAction == CB_TRUE ) ? true : false ;
@@ -1290,9 +1297,8 @@ export default class Datatable extends LightningElement {
1290
1297
// Custom column processing
1291
1298
this . updateColumns ( ) ;
1292
1299
1293
- const firstCol = ( this . hasRowAction && this . rowActionLeftOrRight == "Left" ) ? 1 : 0 ;
1294
- if ( this . cols [ firstCol ] ?. fieldName . endsWith ( '_lookup' ) ) {
1295
- this . sortedBy = this . cols [ 0 ] . fieldName ;
1300
+ if ( this . cols [ this . rowActionColumnOffset ] ?. fieldName . endsWith ( '_lookup' ) ) {
1301
+ this . sortedBy = this . cols [ this . rowActionColumnOffset ] . fieldName ;
1296
1302
this . doSort ( this . sortedBy , 'asc' ) ;
1297
1303
}
1298
1304
@@ -1389,13 +1395,16 @@ export default class Datatable extends LightningElement {
1389
1395
}
1390
1396
1391
1397
// Other processing for reactivity
1392
- this . outputRemovedRows = [ ] ;
1393
- this . numberOfRowsRemoved = 0 ;
1394
- this . outputRemainingRows = [ ] ;
1395
- this . dispatchEvent ( new FlowAttributeChangeEvent ( 'outputRemovedRows' , this . outputRemovedRows ) ) ;
1396
- this . dispatchEvent ( new FlowAttributeChangeEvent ( 'numberOfRowsRemoved' , this . numberOfRowsRemoved ) ) ;
1397
- this . dispatchEvent ( new FlowAttributeChangeEvent ( 'outputRemainingRows' , this . _outputRemainingRows ) ) ;
1398
-
1398
+ if ( ! this . haveProcessedReactivity ) {
1399
+ this . outputRemovedRows = [ ] ;
1400
+ this . numberOfRowsRemoved = 0 ;
1401
+ this . outputRemainingRows = [ ] ;
1402
+ this . dispatchEvent ( new FlowAttributeChangeEvent ( 'outputRemovedRows' , this . outputRemovedRows ) ) ;
1403
+ this . dispatchEvent ( new FlowAttributeChangeEvent ( 'numberOfRowsRemoved' , this . numberOfRowsRemoved ) ) ;
1404
+ this . dispatchEvent ( new FlowAttributeChangeEvent ( 'outputRemainingRows' , this . _outputRemainingRows ) ) ;
1405
+ this . haveProcessedReactivity = true ;
1406
+ }
1407
+
1399
1408
// Clear all existing column filters
1400
1409
this . columnFilterValues = [ ] ;
1401
1410
this . showClearFilterButton = false ;
@@ -2224,7 +2233,11 @@ export default class Datatable extends LightningElement {
2224
2233
if ( sdraft != undefined ) {
2225
2234
let sfieldNames = Object . keys ( sdraft ) ;
2226
2235
sfieldNames . forEach ( sf => {
2227
- sitem [ sf ] = sdraft [ sf ] ;
2236
+ if ( this . percentFieldArray . indexOf ( sf ) != - 1 ) {
2237
+ sitem [ sf ] = parseFloat ( sdraft [ sf ] ) / 100 ;
2238
+ } else {
2239
+ sitem [ sf ] = sdraft [ sf ] ;
2240
+ }
2228
2241
} ) ;
2229
2242
}
2230
2243
return sitem ;
@@ -2369,7 +2382,7 @@ export default class Datatable extends LightningElement {
2369
2382
2370
2383
// Reapply filters (none in place)
2371
2384
this . filterColumnData ( ) ; // v4.3.3 promise/resolve clears selected rows
2372
- this . isWorking = true ;
2385
+ // this.isWorking = true;
2373
2386
// new Promise((resolve, reject) => {
2374
2387
// setTimeout(() => {
2375
2388
// this.filterColumnData();
@@ -2380,15 +2393,16 @@ export default class Datatable extends LightningElement {
2380
2393
// () => this.isWorking = false
2381
2394
// );
2382
2395
2383
- colNumber = 0 ;
2384
- this . columns . forEach ( col => { // Disable all column Clear header actions and reset Labels
2385
- this . columns [ colNumber ] . actions . find ( a => a . name == 'clear_' + colNumber ) . disabled = true ;
2396
+ // Disable all column Clear header actions and reset Labels
2397
+ let colCount = this . columns . length - ( ( this . hasRowAction ) ? 1 : 0 ) ;
2398
+ for ( colNumber = this . rowActionColumnOffset ; colNumber < colCount ; colNumber ++ ) {
2399
+ let actionColRef = colNumber - this . rowActionColumnOffset ; // *** v4.3.6 fix ***
2400
+ this . columns [ colNumber ] . actions . find ( a => a . name == 'clear_' + actionColRef ) . disabled = true ;
2386
2401
this . columns [ colNumber ] . label = this . columns [ colNumber ] . label . split ( ' [' ) [ 0 ] ;
2387
- colNumber ++ ;
2388
- } ) ;
2402
+ }
2389
2403
2390
2404
// Re-Sort the data
2391
- if ( this . sortedBy != undefined ) {
2405
+ if ( this . sortedBy ) {
2392
2406
this . doSort ( this . sortedBy , this . sortDirection ) ;
2393
2407
}
2394
2408
}
@@ -2405,7 +2419,6 @@ export default class Datatable extends LightningElement {
2405
2419
}
2406
2420
2407
2421
doSort ( sortField , sortDirection ) {
2408
-
2409
2422
// Determine if column type will allow field values to be converted to lower case
2410
2423
let isString = false ;
2411
2424
if ( this . isCaseInsensitiveSort ) {
@@ -2447,7 +2460,7 @@ export default class Datatable extends LightningElement {
2447
2460
} )
2448
2461
. then (
2449
2462
( ) => this . isWorking = false
2450
- ) ;
2463
+ ) ;
2451
2464
}
2452
2465
2453
2466
handleHeaderAction ( event ) {
@@ -2459,7 +2472,7 @@ export default class Datatable extends LightningElement {
2459
2472
this . isFiltered = false ;
2460
2473
const colDef = event . detail . columnDefinition ;
2461
2474
this . filterColumns = JSON . parse ( JSON . stringify ( [ ...this . columns ] ) ) ;
2462
- this . columnNumber = Number ( colDef . actions [ 0 ] . name . split ( "_" ) [ 1 ] ) ;
2475
+ this . columnNumber = Number ( colDef . actions [ 0 ] . name . split ( "_" ) [ 1 ] ) + this . rowActionColumnOffset ; // v4.3.6 Use correct column when a left side row action is present
2463
2476
this . baseLabel = this . filterColumns [ this . columnNumber ] . label . split ( ' [' ) [ 0 ] ;
2464
2477
const prompt = ( this . isConfigMode ) ? this . label . LabelHeader : this . label . FilterHeader ;
2465
2478
this . inputLabel = this . label . ColumnHeader + ' ' + prompt + ': ' + this . baseLabel ;
@@ -2563,7 +2576,7 @@ export default class Datatable extends LightningElement {
2563
2576
if ( this . isConfigMode ) {
2564
2577
this . updateLabelParam ( ) ;
2565
2578
}
2566
-
2579
+
2567
2580
this . filterColumnData ( ) ; // v4.3.3 promise/resolve clears selected rows
2568
2581
// this.isWorking = true;
2569
2582
// new Promise((resolve, reject) => {
@@ -2576,8 +2589,9 @@ export default class Datatable extends LightningElement {
2576
2589
// () => this.isWorking = false
2577
2590
// );
2578
2591
2579
- this . filterColumns [ this . columnNumber ] . actions . find ( a => a . name == 'clear_' + this . columnNumber ) . disabled = true ;
2580
- if ( this . sortedBy != undefined ) {
2592
+ let actionColRef = this . columnNumber - this . rowActionColumnOffset ; // *** v4.3.6 fix ***
2593
+ this . filterColumns [ this . columnNumber ] . actions . find ( a => a . name == 'clear_' + actionColRef ) . disabled = true ;
2594
+ if ( this . sortedBy ) {
2581
2595
this . doSort ( this . sortedBy , this . sortDirection ) ; // Re-Sort the data
2582
2596
}
2583
2597
break ;
@@ -2769,6 +2783,7 @@ export default class Datatable extends LightningElement {
2769
2783
}
2770
2784
}
2771
2785
this . columnFilterValues [ this . columnNumber ] = this . columnFilterValue ;
2786
+
2772
2787
// Force a redisplay of the datatable with the filter value shown in the column header
2773
2788
this . columns = [ ...this . filterColumns ] ;
2774
2789
}
@@ -2794,9 +2809,11 @@ export default class Datatable extends LightningElement {
2794
2809
const rows = [ ...this . _savePreEditData ] ;
2795
2810
const cols = this . columnFilterValues ;
2796
2811
let filteredRows = [ ] ;
2812
+ let colCount = cols . length ;
2797
2813
rows . forEach ( row => {
2798
2814
let match = true ;
2799
- for ( let col = 0 ; col < cols . length ; col ++ ) {
2815
+ for ( let col = this . rowActionColumnOffset ; col < colCount ; col ++ ) {
2816
+ let actionColRef = col - this . rowActionColumnOffset ; // *** v4.3.6 fix ***
2800
2817
let fieldName = this . filterColumns [ col ] . fieldName ;
2801
2818
if ( fieldName . endsWith ( '_lookup' ) ) {
2802
2819
fieldName = fieldName . slice ( 0 , fieldName . lastIndexOf ( '_lookup' ) ) + '_name' ;
@@ -2818,20 +2835,20 @@ export default class Datatable extends LightningElement {
2818
2835
break ;
2819
2836
}
2820
2837
break ;
2821
- case 'date-local' :
2822
- let dl = row [ fieldName ] ;
2823
- let dtf = new Intl . DateTimeFormat ( 'en' , {
2824
- year : 'numeric' ,
2825
- month : '2-digit' ,
2826
- day : '2-digit'
2827
- } ) ;
2828
- const [ { value : mo } , , { value : da } , , { value : ye } ] = dtf . formatToParts ( dl ) ;
2829
- let formatedDate = `${ ye } -${ mo } -${ da } ` ;
2830
- if ( formatedDate != this . columnFilterValues [ col ] ) { // Check for date match on date & time fields
2831
- match = false ;
2832
- break ;
2833
- }
2834
- break ;
2838
+ case 'date-local' : // v4.3.6 - Handle like regular date due to changes made in v4.3.5
2839
+ // let dl = row[fieldName];
2840
+ // let dtf = new Intl.DateTimeFormat('en', {
2841
+ // year: 'numeric',
2842
+ // month: '2-digit',
2843
+ // day: '2-digit'
2844
+ // });
2845
+ // const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dl);
2846
+ // let formatedDate = `${ye}-${mo}-${da}`;
2847
+ // if (formatedDate != this.columnFilterValues[col]) { // Check for date match on date & time fields
2848
+ // match = false;
2849
+ // break;
2850
+ // }
2851
+ // break;
2835
2852
case 'date' :
2836
2853
case 'datetime' :
2837
2854
case 'time' :
@@ -2862,10 +2879,10 @@ export default class Datatable extends LightningElement {
2862
2879
}
2863
2880
}
2864
2881
this . isFiltered = true ;
2865
- this . filterColumns [ col ] . actions . find ( a => a . name == 'clear_' + col ) . disabled = false ;
2882
+ this . filterColumns [ col ] . actions . find ( a => a . name == 'clear_' + actionColRef ) . disabled = false ;
2866
2883
} else {
2867
2884
if ( this . filterColumns [ col ] . actions && this . filterColumns [ col ] . actions != null ) { // *** v4.2.1 fix ***
2868
- this . filterColumns [ col ] . actions . find ( a => a . name == 'clear_' + col ) . disabled = true ;
2885
+ this . filterColumns [ col ] . actions . find ( a => a . name == 'clear_' + actionColRef ) . disabled = true ;
2869
2886
}
2870
2887
}
2871
2888
}
@@ -2901,9 +2918,11 @@ export default class Datatable extends LightningElement {
2901
2918
const rows = this . _filteredData . length > 0 ? [ ...this . _filteredData ] : [ ...this . _savePreEditData ] ;
2902
2919
const cols = this . columns ;
2903
2920
let filteredRows = [ ] ;
2921
+ let colCount = cols . length ;
2904
2922
rows . forEach ( row => {
2905
2923
let match = false ;
2906
- for ( let col = 0 ; col < cols . length ; col ++ ) {
2924
+ // for (let col = this.rowActionColumnOffset; col < colCount; col++) {
2925
+ for ( let col = 0 ; col < colCount ; col ++ ) {
2907
2926
let fieldName = cols [ col ] . fieldName ;
2908
2927
if ( fieldName ?. endsWith ( '_lookup' ) ) {
2909
2928
fieldName = fieldName . slice ( 0 , fieldName . lastIndexOf ( '_lookup' ) ) + '_name' ;
@@ -2922,20 +2941,20 @@ export default class Datatable extends LightningElement {
2922
2941
break ;
2923
2942
}
2924
2943
break ;
2925
- case 'date-local' :
2926
- let dl = row [ fieldName ] ;
2927
- let dtf = new Intl . DateTimeFormat ( 'en' , {
2928
- year : 'numeric' ,
2929
- month : '2-digit' ,
2930
- day : '2-digit'
2931
- } ) ;
2932
- const [ { value : mo } , , { value : da } , , { value : ye } ] = dtf . formatToParts ( dl ) ;
2933
- let formatedDate = `${ ye } -${ mo } -${ da } ` ;
2934
- if ( formatedDate == searchTerm ) { // Check for date match on date & time fields
2935
- match = true ;
2936
- break ;
2937
- }
2938
- break ;
2944
+ case 'date-local' : // v4.3.6 - Handle like regular date due to changes made in v4.3.5
2945
+ // let dl = row[fieldName]" ;
2946
+ // let dtf = new Intl.DateTimeFormat('en', {
2947
+ // year: 'numeric',
2948
+ // month: '2-digit',
2949
+ // day: '2-digit'
2950
+ // });
2951
+ // const [{value: mo}, , {value: da}, , {value: ye}] = dtf.formatToParts(dl);
2952
+ // let formatedDate = `${ye}-${mo}-${da}`;
2953
+ // if (formatedDate == searchTerm) { // Check for date match on date & time fields
2954
+ // match = true;
2955
+ // break;
2956
+ // }
2957
+ // break;
2939
2958
case 'date' :
2940
2959
case 'datetime' :
2941
2960
case 'time' :
@@ -2950,7 +2969,7 @@ export default class Datatable extends LightningElement {
2950
2969
break ;
2951
2970
default :
2952
2971
let fieldValue = row [ fieldName ] . toString ( ) ;
2953
- let filterValue = searchTerm ?. replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ; // v4.3.5 escape special characters
2972
+ let filterValue = searchTerm ?. replace ( / [ . * + ? ^ $ { } ( ) | [ \] \\ ] / g, '\\$&' ) ; // v4.3.5 escape special characters
2954
2973
if ( ! this . matchCaseOnFilters ) {
2955
2974
fieldValue = fieldValue . toLowerCase ( ) ;
2956
2975
filterValue = filterValue . toLowerCase ( ) ;
0 commit comments