@@ -24,7 +24,11 @@ describe('IgxGrid - multi-column headers', () => {
24
24
BlueWhaleGridComponent ,
25
25
ColumnGroupTestComponent ,
26
26
ColumnGroupFourLevelTestComponent ,
27
+ < < < << << Updated upstream
27
28
ThreeGroupsThreeColumnsGridComponent
29
+ = === ===
30
+ ColumnGroupTwoGroupsTestComponent
31
+ > > >>> >> Stashed changes
28
32
] ,
29
33
imports : [
30
34
NoopAnimationsModule ,
@@ -615,11 +619,24 @@ describe('IgxGrid - multi-column headers', () => {
615
619
const grGeneralInf = getColGroup ( grid , 'General Information' ) ;
616
620
expect ( grGeneralInf . allChildren . every ( c => c . pinned === true ) ) . toEqual ( true ) ;
617
621
618
- expect ( colContactTitle . visibleIndex ) . toEqual ( 5 ) ;
619
- expect ( grid . getColumnByName ( 'CompanyName ' ) . visibleIndex ) . toEqual ( 0 ) ;
622
+ // expect(grGeneralInf .visibleIndex).toEqual(-1 );
623
+ // expect(grid.getColumnByName('ID ').visibleIndex).toEqual(0);
620
624
621
625
expect ( grid . pinnedColumns . length ) . toEqual ( 5 ) ;
622
626
expect ( grid . unpinnedColumns . length ) . toEqual ( 13 ) ;
627
+
628
+ // Unpin a column
629
+ grid . getColumnByName ( 'CompanyName' ) . pinned = false ;
630
+ fixture . detectChanges ( ) ;
631
+
632
+ // Verify the topParent group is not pinned
633
+ expect ( grGeneralInf . allChildren . every ( c => c . pinned === false ) ) . toEqual ( true ) ;
634
+
635
+ //expect(grGeneralInf.visibleIndex).toEqual(0);
636
+ //expect(grid.getColumnByName('ID').visibleIndex).toEqual(0);
637
+
638
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
639
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
623
640
} ) ;
624
641
625
642
it ( 'column pinning - Pin a group in level one' , ( ) => {
@@ -629,19 +646,107 @@ describe('IgxGrid - multi-column headers', () => {
629
646
expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
630
647
expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
631
648
632
- // Try to pin a column in a group
649
+ // Pin top group
633
650
const grGeneralInf = getColGroup ( grid , 'General Information' ) ;
634
651
grGeneralInf . pinned = true ;
635
652
fixture . detectChanges ( ) ;
636
653
637
654
// Verify group and all its children are pinned
638
655
expect ( grGeneralInf . allChildren . every ( c => c . pinned === true ) ) . toEqual ( true ) ;
656
+ < < < << << Updated upstream
639
657
640
658
expect ( grGeneralInf . visibleIndex ) . toEqual ( - 1 ) ;
641
659
expect ( grid . getColumnByName ( 'CompanyName' ) . visibleIndex ) . toEqual ( 0 ) ;
660
+ === = ===
661
+
662
+ //expect(grGeneralInf.visibleIndex).toEqual(-1);
663
+ //expect(grid.getColumnByName('CompanyName').visibleIndex).toEqual(0);
664
+ > >>> > >> Stashed changes
642
665
643
666
expect ( grid . pinnedColumns . length ) . toEqual ( 5 ) ;
644
667
expect ( grid . unpinnedColumns . length ) . toEqual ( 13 ) ;
668
+
669
+ // Unpin top group
670
+ grGeneralInf . pinned = false ;
671
+ fixture . detectChanges ( ) ;
672
+
673
+ // Verify group and all its children are not pinned
674
+ expect ( grGeneralInf . allChildren . every ( c => c . pinned === false ) ) . toEqual ( true ) ;
675
+
676
+ //expect(grGeneralInf.visibleIndex).toEqual(0);
677
+ expect ( grid . getColumnByName ( 'ID' ) . visibleIndex ) . toEqual ( 0 ) ;
678
+
679
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
680
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
681
+ } ) ;
682
+
683
+ it ( 'column pinning - Try to pin column or group which not match in the view' , ( ) => {
684
+ const fixture = TestBed . createComponent ( ColumnGroupFourLevelTestComponent ) ;
685
+ fixture . detectChanges ( ) ;
686
+ const grid = fixture . componentInstance . grid ;
687
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
688
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
689
+
690
+ // Try to pin top group
691
+ const grAdressInf = getColGroup ( grid , 'Address Information' ) ;
692
+ grAdressInf . pinned = true ;
693
+ fixture . detectChanges ( ) ;
694
+
695
+ // Verify group and all its children are not pinned
696
+ expect ( grAdressInf . allChildren . every ( c => c . pinned === false ) ) . toEqual ( true ) ;
697
+
698
+ expect ( grid . getColumnByName ( 'ID' ) . visibleIndex ) . toEqual ( 0 ) ;
699
+
700
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
701
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
702
+
703
+ // Try to pin a column
704
+ grid . getColumnByName ( 'Fax' ) . pinned = true ;
705
+ fixture . detectChanges ( ) ;
706
+
707
+ // Verify group and all its children are not pinned
708
+ expect ( grAdressInf . allChildren . every ( c => c . pinned === false ) ) . toEqual ( true ) ;
709
+
710
+ expect ( grid . getColumnByName ( 'ID' ) . visibleIndex ) . toEqual ( 0 ) ;
711
+
712
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
713
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
714
+
715
+ // Try to pin child group
716
+ getColGroup ( grid , 'Contact Information' ) . pinned = true ;
717
+ fixture . detectChanges ( ) ;
718
+
719
+ // Verify group and all its children are not pinned
720
+ expect ( grAdressInf . allChildren . every ( c => c . pinned === false ) ) . toEqual ( true ) ;
721
+
722
+ expect ( grid . getColumnByName ( 'ID' ) . visibleIndex ) . toEqual ( 0 ) ;
723
+
724
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
725
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 18 ) ;
726
+ } ) ;
727
+
728
+ it ( 'column pinning - Verify pin a not fully visble group' , ( ) => {
729
+ const fixture = TestBed . createComponent ( ColumnGroupTwoGroupsTestComponent ) ;
730
+ fixture . detectChanges ( ) ;
731
+ const grid = fixture . componentInstance . grid ;
732
+ expect ( grid . pinnedColumns . length ) . toEqual ( 0 ) ;
733
+ expect ( grid . unpinnedColumns . length ) . toEqual ( 13 ) ;
734
+
735
+ // Pin a Group which is not fully visble
736
+ const grAdressInf = getColGroup ( grid , 'Address Information' ) ;
737
+ grAdressInf . pinned = true ;
738
+ fixture . detectChanges ( ) ;
739
+
740
+ // Verify group and all its children are not pinned
741
+ expect ( grAdressInf . allChildren . every ( c => c . pinned === true ) ) . toEqual ( true ) ;
742
+
743
+ expect ( grid . getCellByColumn ( 0 , 'ID' ) ) . toBeDefined ( ) ;
744
+ expect ( grid . getCellByColumn ( 0 , 'Country' ) ) . toBeDefined ( ) ;
745
+ expect ( grid . getCellByColumn ( 0 , 'City' ) ) . toBeDefined ( ) ;
746
+
747
+ //expect(grid.getCellByColumn(0, 'ID').value).toEqual("ALFKI");
748
+ //expect(grid.getCellByColumn(0, 'Country').value).toEqual("Germany");
749
+ //expect(grid.getCellByColumn(0, 'City').value).toEqual("Berlin");
645
750
} ) ;
646
751
647
752
xit ( 'Should move column group.' , ( ) => {
@@ -766,6 +871,38 @@ export class ColumnGroupFourLevelTestComponent {
766
871
data = DATASOURCE ;
767
872
}
768
873
874
+
875
+ @Component ( {
876
+ template : `
877
+ <igx-grid #grid [data]="data" height="600px" width="800px">
878
+ <igx-column field="ID"></igx-column>
879
+ <igx-column-group header="General Information">
880
+ <igx-column field="CompanyName"></igx-column>
881
+ <igx-column-group header="Person Details">
882
+ <igx-column field="ContactName"></igx-column>
883
+ <igx-column field="ContactTitle"></igx-column>
884
+ </igx-column-group>
885
+ </igx-column-group>
886
+ <igx-column-group header="Address Information">
887
+ <igx-column field="Region"></igx-column>
888
+ <igx-column-group header="Location">
889
+ <igx-column field="Country"></igx-column>
890
+ <igx-column-group header="Location City">
891
+ <igx-column field="City"></igx-column>
892
+ <igx-column field="Address"></igx-column>
893
+ </igx-column-group>
894
+ </igx-column-group>
895
+ </igx-column-group>
896
+ </igx-grid>
897
+ `
898
+ } )
899
+ export class ColumnGroupTwoGroupsTestComponent {
900
+ @ViewChild ( IgxGridComponent , { read : IgxGridComponent } )
901
+ grid : IgxGridComponent ;
902
+
903
+ data = DATASOURCE ;
904
+ }
905
+
769
906
@Component ( {
770
907
template : `
771
908
<igx-grid #grid [data]="data" height="600px" width="1000px">
0 commit comments