@@ -23,15 +23,22 @@ import { flatten } from '../../core/utils';
2323 template : ``
2424} )
2525export class IgxColumnGroupComponent extends IgxColumnComponent implements AfterContentInit {
26- private _collapsible = false ;
27- private _expanded = true ;
2826
2927 @ContentChildren ( IgxColumnComponent , { read : IgxColumnComponent } )
3028 children = new QueryList < IgxColumnComponent > ( ) ;
3129
30+ /**
31+ * Set if the column group is collapsible.
32+ * Default value is `false`
33+ * ```html
34+ * <igx-column-group [collapsible] = "true"></igx-column-group>
35+ * ```
36+ * @memberof IgxColumnGroupComponent
37+ */
3238 @Input ( )
3339 public set collapsible ( value : boolean ) {
3440 this . _collapsible = value ;
41+ this . collapsibleChange . emit ( this . _collapsible ) ;
3542 if ( this . children ) {
3643 if ( value ) {
3744 this . setExpandCollapseState ( ) ;
@@ -44,17 +51,28 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
4451 return this . _collapsible ;
4552 }
4653
54+ /**
55+ * Set whether the group is expanded or collapsed initially.
56+ * Applied only if the collapsible property is set to `true`
57+ * Default value is `true`
58+ * ```html
59+ * const state = false
60+ * <igx-column-group [(expand)] = "state"></igx-column-group>
61+ * ```
62+ * @memberof IgxColumnGroupComponent
63+ */
4764 @Input ( )
48- public get expanded ( ) {
49- return this . _expanded ;
50- }
51- public set expanded ( value : boolean ) {
52- this . _expanded = value ;
65+ public set expand ( value : boolean ) {
5366 if ( ! this . collapsible ) { return ; }
67+ this . _expand = value ;
68+ this . expandChange . emit ( this . _expand ) ;
5469 if ( ! this . hidden && this . children ) {
5570 this . setExpandCollapseState ( ) ;
5671 }
5772 }
73+ public get expand ( ) {
74+ return this . _expand ;
75+ }
5876
5977 /**
6078 * Gets the column group `summaries`.
@@ -123,6 +141,18 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
123141 */
124142 set bodyTemplate ( template : TemplateRef < any > ) { }
125143
144+ /**
145+ * Allows you to define a custom template for expand/collapse indicator
146+ * @memberof IgxColumnGroupComponent
147+ */
148+ @Input ( )
149+ get collapsibleIndicatorTemplate ( ) : TemplateRef < any > {
150+ return this . _collapseIndicatorTemplate ;
151+ }
152+ set collapsibleIndicatorTemplate ( template : TemplateRef < any > ) {
153+ this . _collapseIndicatorTemplate = template ;
154+ }
155+
126156 /**
127157 * Returns a reference to the inline editor template.
128158 * ```typescript
@@ -177,8 +207,8 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
177207 this . children . forEach ( child => child . hidden = value ) ;
178208 } else {
179209 this . children . forEach ( c => {
180- if ( c . openOnGroupCollapsed === undefined ) { c . hidden = false ; return ; }
181- c . hidden = this . expanded ? c . openOnGroupCollapsed : ! c . openOnGroupCollapsed ;
210+ if ( c . visibleOnCollapse === undefined ) { c . hidden = false ; return ; }
211+ c . hidden = this . expand ? c . visibleOnCollapse : ! c . visibleOnCollapse ;
182212 } ) ;
183213 }
184214 }
@@ -200,6 +230,9 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
200230 if ( this . headTemplate && this . headTemplate . length ) {
201231 this . _headerTemplate = this . headTemplate . toArray ( ) [ 0 ] . template ;
202232 }
233+ if ( this . collapseIndicatorTemplate ) {
234+ this . _collapseIndicatorTemplate = this . collapseIndicatorTemplate . template ;
235+ }
203236 // currently only ivy fixes the issue, we have to slice only if the first child is group
204237 if ( this . children . first === this ) {
205238 this . children . reset ( this . children . toArray ( ) . slice ( 1 ) ) ;
@@ -208,7 +241,7 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
208241 child . parent = this ;
209242 } ) ;
210243 if ( this . collapsible ) {
211- const cols = this . children . map ( child => child . openOnGroupCollapsed ) ;
244+ const cols = this . children . map ( child => child . visibleOnCollapse ) ;
212245 if ( ! ( cols . some ( c => c === true ) && cols . some ( c => c === false ) ) ) {
213246 this . collapsible = false ;
214247 return ;
@@ -271,8 +304,8 @@ export class IgxColumnGroupComponent extends IgxColumnComponent implements After
271304 set width ( val ) { }
272305
273306 private setExpandCollapseState ( ) {
274- this . children . filter ( col => ( col . openOnGroupCollapsed !== undefined ) ) . forEach ( c => {
275- c . hidden = this . _expanded ? c . openOnGroupCollapsed : ! c . openOnGroupCollapsed ;
307+ this . children . filter ( col => ( col . visibleOnCollapse !== undefined ) ) . forEach ( c => {
308+ c . hidden = this . _expand ? c . visibleOnCollapse : ! c . visibleOnCollapse ;
276309 } ) ;
277310 }
278311
0 commit comments