@@ -21,7 +21,7 @@ import { IgxExcelStyleHeaderComponent } from '../filtering/excel-style/excel-sty
2121import { IgxExcelStyleSortingComponent } from '../filtering/excel-style/excel-style-sorting.component' ;
2222import { IgxExcelStyleSearchComponent } from '../filtering/excel-style/excel-style-search.component' ;
2323import { IgxCellHeaderTemplateDirective } from '../columns/templates.directive' ;
24- import { CellType , ColumnType , IGridCellEventArgs , IgxColumnComponent , IgxRowEditActionsDirective , IgxRowEditTextDirective } from '../public_api' ;
24+ import { CellType , ColumnType , IGridCellEventArgs , IgxColumnComponent , IgxColumnGroupComponent , IgxRowEditActionsDirective , IgxRowEditTextDirective } from '../public_api' ;
2525import { getComponentSize } from '../../core/utils' ;
2626
2727describe ( 'Basic IgxHierarchicalGrid #hGrid' , ( ) => {
@@ -42,7 +42,8 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
4242 IgxHierarchicalGridAutoSizeColumnsComponent ,
4343 IgxHierarchicalGridCustomTemplateComponent ,
4444 IgxHierarchicalGridCustomFilteringTemplateComponent ,
45- IgxHierarchicalGridToggleRIAndColsComponent
45+ IgxHierarchicalGridToggleRIAndColsComponent ,
46+ IgxHierarchicalGridMCHComponent
4647 ]
4748 } ) . compileComponents ( ) ;
4849 } ) )
@@ -1713,6 +1714,42 @@ describe('Basic IgxHierarchicalGrid #hGrid', () => {
17131714 } ) ) ;
17141715 } ) ;
17151716
1717+ describe ( 'IgxHierarchicalGrid Multi-Column Headers' , ( ) => {
1718+ let fixture : ComponentFixture < IgxHierarchicalGridMCHComponent > ;
1719+ let hierarchicalGrid : IgxHierarchicalGridComponent ;
1720+
1721+ beforeEach ( ( ) => {
1722+ fixture = TestBed . createComponent ( IgxHierarchicalGridMCHComponent ) ;
1723+ fixture . detectChanges ( ) ;
1724+ hierarchicalGrid = fixture . componentInstance . hGrid ;
1725+ } ) ;
1726+
1727+ it ( 'should fire expandedChange, hiddenChange and pinnedChange events for child grid.' , ( ) => {
1728+ const childGrid = hierarchicalGrid . gridAPI . getChildGrids ( false ) [ 0 ] ;
1729+ const columnGroup2 = childGrid . columns [ 4 ] as IgxColumnGroupComponent ;
1730+ const columnGroup2Header = GridFunctions . getColumnGroupHeaders ( fixture ) [ 3 ] ;
1731+ const expandIcon = columnGroup2Header . queryAll ( By . css ( '.igx-icon' ) ) [ 0 ] ;
1732+ const pinIcon = columnGroup2Header . queryAll ( By . css ( '.igx-icon' ) ) [ 1 ] ;
1733+
1734+ expect ( columnGroup2 . expanded ) . toBeFalsy ( ) ;
1735+ expect ( columnGroup2 . pinned ) . toBeFalsy ( ) ;
1736+
1737+ UIInteractions . simulateClickEvent ( expandIcon . nativeElement ) ;
1738+ fixture . detectChanges ( ) ;
1739+
1740+ expect ( columnGroup2 . expanded ) . toBeTruthy ( ) ;
1741+
1742+ expect ( fixture . componentInstance . expandedArgs ) . toBeDefined ( ) ;
1743+ expect ( fixture . componentInstance . expandedArgs ) . not . toBe ( false ) ;
1744+ expect ( fixture . componentInstance . hiddenArgs ) . toBeDefined ( ) ;
1745+
1746+ UIInteractions . simulateClickEvent ( pinIcon . nativeElement ) ;
1747+ fixture . detectChanges ( ) ;
1748+
1749+ expect ( columnGroup2 . pinned ) . toBeTruthy ( ) ;
1750+ expect ( fixture . componentInstance . pinnedArgs ) . toBeDefined ( ) ;
1751+ } ) ;
1752+ } ) ;
17161753} ) ;
17171754
17181755@Component ( {
@@ -2131,3 +2168,93 @@ export class IgxHierarchicalGridCustomRowEditOverlayComponent extends IgxHierarc
21312168 imports : [ IgxHierarchicalGridComponent , IgxColumnComponent , IgxRowIslandComponent , IgxRowEditTextDirective , IgxRowEditActionsDirective ]
21322169} )
21332170export class IgxHierarchicalGridAutoSizeColumnsComponent extends IgxHierarchicalGridTestBaseComponent { }
2171+
2172+ @Component ( {
2173+ template : `
2174+ <ng-template #headerTemplate igxHeader let-col>
2175+ <span >{{ col.header ? col.header : col.field}}</span>
2176+ <igx-icon (click)="pinColumn(col)">push_pin</igx-icon>
2177+ </ng-template>
2178+ <igx-hierarchical-grid #hGrid [data]="data" [height]="'400px'" [width]="'800px'" [expandChildren]="true">
2179+ <igx-column field="CustomerID"></igx-column>
2180+ <igx-column-group header="General Information" [collapsible]="true" [expanded]="false">
2181+ <igx-column field="CompanyName" [visibleWhenCollapsed]="true"></igx-column>
2182+ <igx-column field="ContactName" [visibleWhenCollapsed]="false"></igx-column>
2183+ <igx-column field="ContactTitle" [visibleWhenCollapsed]="false"></igx-column>
2184+ </igx-column-group>
2185+ <igx-column-group header="Address Information" [collapsible]="true" [expanded]="false">
2186+ <igx-column field="Location" [visibleWhenCollapsed]="true"></igx-column>
2187+ <igx-column field="Address" [visibleWhenCollapsed]="false"></igx-column>
2188+ <igx-column field="City" [visibleWhenCollapsed]="false"></igx-column>
2189+ <igx-column field="Country" [visibleWhenCollapsed]="false"></igx-column>
2190+ <igx-column field="PostalCode" [visibleWhenCollapsed]="false"></igx-column>
2191+ </igx-column-group>
2192+ <igx-row-island [height]="null" [key]="'Orders'" [autoGenerate]="false">
2193+ <igx-column-group header="Order Details" [collapsible]="true" [expanded]="false">
2194+ <igx-column field="OrderID" [visibleWhenCollapsed]="true"></igx-column>
2195+ <igx-column field="OrderDate" [dataType]="'date'" [visibleWhenCollapsed]="false"></igx-column>
2196+ <igx-column field="RequiredDate" [dataType]="'date'" [visibleWhenCollapsed]="false"></igx-column>
2197+ </igx-column-group>
2198+ <igx-column-group header="General Shipping Information" [collapsible]="true" [expanded]="false"
2199+ [headerTemplate]="headerTemplate" (expandedChange)="expandedChange($event)">
2200+ <igx-column field="ShippedDate" [dataType]="'date'" [visibleWhenCollapsed]="true"
2201+ (hiddenChange)="hiddenChange($event)" (pinnedChange)="pinnedChange($event)"></igx-column>
2202+ <igx-column field="ShipVia" [visibleWhenCollapsed]="false" ></igx-column>
2203+ <igx-column field="Freight" [visibleWhenCollapsed]="false"></igx-column>
2204+ <igx-column field="ShipName" [visibleWhenCollapsed]="false"></igx-column>
2205+ </igx-column-group>
2206+ </igx-row-island>
2207+ </igx-hierarchical-grid>
2208+ ` ,
2209+ standalone : true ,
2210+ imports : [ IgxHierarchicalGridComponent , IgxRowIslandComponent , IgxColumnComponent , IgxColumnGroupComponent , IgxIconComponent , IgxCellHeaderTemplateDirective ]
2211+ } )
2212+ export class IgxHierarchicalGridMCHComponent {
2213+ @ViewChild ( 'hGrid' , { read : IgxHierarchicalGridComponent , static : true } )
2214+ public hGrid : IgxHierarchicalGridComponent ;
2215+
2216+ public expandedArgs : any ;
2217+ public hiddenArgs : any ;
2218+ public pinnedArgs : any ;
2219+
2220+ public data = [
2221+ {
2222+ CustomerID : "VINET" ,
2223+ CompanyName : "Vins et alcools Chevalier" ,
2224+ ContactName : "Paul Henriot" ,
2225+ ContactTitle : "Accounting Manager" ,
2226+ Location : "59 rue de l'Abbaye, Reims, France" ,
2227+ Address : "59 rue de l'Abbaye" ,
2228+ City : "Reims" ,
2229+ Country : "France" ,
2230+ PostalCode : "51100" ,
2231+ Orders : [
2232+ {
2233+ OrderID : 10248 ,
2234+ OrderDate : new Date ( "1996-07-04T00:00:00" ) ,
2235+ RequiredDate : new Date ( "1996-08-01T00:00:00" ) ,
2236+ ShippedDate : new Date ( "1996-07-16T00:00:00" ) ,
2237+ ShipVia : 3 ,
2238+ Freight : 32.38 ,
2239+ ShipName : "Vins et alcools Chevalier" ,
2240+ } ,
2241+ ] ,
2242+ } ,
2243+ ] ;
2244+
2245+ public pinColumn ( col : ColumnType ) {
2246+ col . pinned ? col . unpin ( ) : col . pin ( ) ;
2247+ }
2248+
2249+ public expandedChange ( args : any ) {
2250+ this . expandedArgs = args ;
2251+ }
2252+
2253+ public hiddenChange ( args : any ) {
2254+ this . hiddenArgs = args ;
2255+ }
2256+
2257+ public pinnedChange ( args : any ) {
2258+ this . pinnedArgs = args ;
2259+ }
2260+ }
0 commit comments