@@ -151,7 +151,7 @@ export class IgxColumnComponent implements AfterContentInit {
151
151
public set pinned ( value : boolean ) {
152
152
if ( this . _pinned !== value ) {
153
153
if ( this . grid && this . width && ! isNaN ( parseInt ( this . width , 10 ) ) ) {
154
- value ? this . _pinColumn ( ) : this . _unpinColumn ( ) ;
154
+ value ? this . pin ( ) : this . unpin ( ) ;
155
155
return ;
156
156
}
157
157
/* No grid/width available at initialization. `initPinning` in the grid
@@ -235,17 +235,20 @@ export class IgxColumnComponent implements AfterContentInit {
235
235
236
236
get visibleIndex ( ) : number {
237
237
const grid = this . gridAPI . get ( this . gridID ) ;
238
+ const unpinnedColumns = this . grid . unpinnedColumns . filter ( c => ! c . columnGroup ) ;
239
+ const pinnedColumns = this . grid . pinnedColumns . filter ( c => ! c . columnGroup ) ;
240
+ let col = this ;
238
241
let vIndex = - 1 ;
239
242
240
243
if ( this . columnGroup ) {
241
- return vIndex ;
244
+ col = this . allChildren . filter ( c => ! c . columnGroup ) [ 0 ] as any ;
242
245
}
243
246
244
247
if ( ! this . pinned ) {
245
- const indexInCollection = grid . unpinnedColumns . indexOf ( this ) ;
246
- vIndex = indexInCollection === - 1 ? - 1 : grid . pinnedColumns . length + indexInCollection ;
248
+ const indexInCollection = unpinnedColumns . indexOf ( col ) ;
249
+ vIndex = indexInCollection === - 1 ? - 1 : pinnedColumns . length + indexInCollection ;
247
250
} else {
248
- vIndex = grid . pinnedColumns . indexOf ( this ) ;
251
+ vIndex = pinnedColumns . indexOf ( col ) ;
249
252
}
250
253
return vIndex ;
251
254
}
@@ -360,24 +363,27 @@ export class IgxColumnComponent implements AfterContentInit {
360
363
}
361
364
}
362
365
363
- public _pinColumn ( index ?) {
366
+ public pin ( index ?) {
364
367
// TODO: Probably should the return type of the old functions
365
368
// should be moved as a event parameter.
366
369
370
+ if ( this . _pinned ) {
371
+ return false ;
372
+ }
373
+
367
374
if ( this . parent && ! this . parent . pinned ) {
368
- this . topLevelParent . pinned = true ;
369
- return ;
375
+ return this . topLevelParent . pin ( index ) ;
370
376
}
371
377
372
378
const grid = ( this . grid as any ) ;
373
379
const width = parseInt ( this . width , 10 ) ;
380
+ const oldIndex = this . visibleIndex ;
374
381
375
382
if ( grid . getUnpinnedWidth ( true ) - width < grid . unpinnedAreaMinWidth ) {
376
383
return false ;
377
384
}
378
385
379
386
this . _pinned = true ;
380
- const oldIndex = this . visibleIndex ;
381
387
this . _unpinnedIndex = grid . _unpinnedColumns . indexOf ( this ) ;
382
388
index = index !== undefined ? index : grid . _pinnedColumns . length ;
383
389
const args = { column : this , insertAtIndex : index } ;
@@ -394,22 +400,28 @@ export class IgxColumnComponent implements AfterContentInit {
394
400
if ( this . columnGroup ) {
395
401
this . children . forEach ( child => child . pinned = true ) ;
396
402
}
397
- grid . reinitPinStates ( ) ;
403
+ // grid.reinitPinStates();
398
404
399
405
grid . markForCheck ( ) ;
400
406
const newIndex = this . visibleIndex ;
401
407
this . updateHighlights ( oldIndex , newIndex ) ;
408
+ return true ;
402
409
}
403
410
404
- public _unpinColumn ( index ?) {
411
+ public unpin ( index ?) {
412
+
413
+ if ( ! this . _pinned ) {
414
+ return false ;
415
+ }
416
+
405
417
if ( this . parent && this . parent . pinned ) {
406
- this . topLevelParent . pinned = false ;
407
- return ;
418
+ return this . topLevelParent . unpin ( index ) ;
408
419
}
409
420
410
421
const grid = ( this . grid as any ) ;
411
422
const oldIndex = this . visibleIndex ;
412
- index = index !== undefined ? index : this . _unpinnedIndex ;
423
+ index = ( index !== undefined ? index :
424
+ this . _unpinnedIndex !== undefined ? this . _unpinnedIndex : this . index ) ;
413
425
this . _pinned = false ;
414
426
415
427
grid . _unpinnedColumns . splice ( index , 0 , this ) ;
@@ -425,6 +437,7 @@ export class IgxColumnComponent implements AfterContentInit {
425
437
grid . markForCheck ( ) ;
426
438
const newIndex = this . visibleIndex ;
427
439
this . updateHighlights ( oldIndex , newIndex ) ;
440
+ return true ;
428
441
}
429
442
430
443
get topLevelParent ( ) {
0 commit comments