11import { Component , CUSTOM_ELEMENTS_SCHEMA , OnInit , inject } from '@angular/core' ;
22import { CommonModule } from '@angular/common' ;
3- import { defineComponents , IgcButtonComponent , IgcCheckboxComponent , IgcDropdownComponent , IgcSwitchComponent } from 'igniteui-webcomponents' ;
3+ import { IgxButtonDirective , IgxToggleActionDirective } from 'igniteui-angular/directives' ;
4+ import { IgxCheckboxComponent } from 'igniteui-angular/checkbox' ;
5+ import { IgxDropDownComponent , IgxDropDownItemComponent , IgxDropDownItemNavigationDirective } from 'igniteui-angular/drop-down' ;
46import { IgcGridLite } from 'igniteui-grid-lite' ;
7+ import { defineComponents , IgcRatingComponent } from 'igniteui-webcomponents' ;
58import { GridLiteDataService , ProductInfo } from '../grid-lite-data.service' ;
69
710IgcGridLite . register ( ) ;
8- defineComponents ( IgcCheckboxComponent , IgcDropdownComponent , IgcSwitchComponent , IgcButtonComponent ) ;
11+ defineComponents ( IgcRatingComponent ) ;
912
1013@Component ( {
1114 selector : 'app-grid-lite-column-config-dynamic' ,
1215 templateUrl : './grid-lite-column-config-dynamic.component.html' ,
1316 styleUrls : [ './grid-lite-column-config-dynamic.component.scss' ] ,
14- imports : [ CommonModule ] ,
15- schemas : [ CUSTOM_ELEMENTS_SCHEMA ]
17+ imports : [
18+ CommonModule ,
19+ IgxButtonDirective ,
20+ IgxToggleActionDirective ,
21+ IgxDropDownItemNavigationDirective ,
22+ IgxDropDownComponent ,
23+ IgxDropDownItemComponent ,
24+ IgxCheckboxComponent
25+ ] ,
26+ schemas : [ CUSTOM_ELEMENTS_SCHEMA ] ,
27+ standalone : true
1628} )
1729export class GridLiteColumnConfigDynamicComponent implements OnInit {
1830 private dataService = inject ( GridLiteDataService ) ;
1931
2032 public data : ProductInfo [ ] = [ ] ;
2133 public hasFormatters = true ;
2234
23- public formatter = new Intl . NumberFormat ( 'en-150' , {
24- style : 'currency' ,
25- currency : 'EUR'
26- } ) ;
35+ public columns = [
36+ { field : 'id' , header : 'ID' , hidden : true , resizable : true , sortable : false , filterable : false } ,
37+ { field : 'name' , header : 'Product Name' , hidden : false , resizable : true , sortable : false , filterable : false } ,
38+ { field : 'price' , header : 'Price' , hidden : false , resizable : true , sortable : false , filterable : false } ,
39+ { field : 'sold' , header : 'Units sold' , hidden : false , resizable : true , sortable : false , filterable : false , dataType : 'number' } ,
40+ { field : 'total' , header : 'Total sold' , hidden : false , resizable : true , sortable : false , filterable : false } ,
41+ { field : 'rating' , header : 'Customer rating' , hidden : false , resizable : true , sortable : false , filterable : false , dataType : 'number' }
42+ ] ;
43+
44+ public formatter = new Intl . NumberFormat ( 'en-150' , { style : 'currency' , currency : 'EUR' } ) ;
2745
2846 ngOnInit ( ) {
2947 this . data = this . dataService . generateProducts ( 50 ) ;
3048 }
3149
32- protected formatCurrency = ( params : any ) => {
33- return this . formatter . format ( params . value ) ;
34- } ;
50+ protected formatCurrency = ( params : any ) => this . formatter . format ( params . value ) ;
3551
3652 protected ratingTemplate = ( params : any ) => {
3753 const rating = document . createElement ( 'igc-rating' ) ;
@@ -40,4 +56,14 @@ export class GridLiteColumnConfigDynamicComponent implements OnInit {
4056 rating . setAttribute ( 'value' , params . value . toString ( ) ) ;
4157 return rating ;
4258 } ;
59+
60+ toggleColumnProperty ( column : any , property : string , value : boolean ) {
61+ column [ property ] = value ;
62+ // Trigger Angular change detection
63+ this . columns = [ ...this . columns ] ;
64+ }
65+
66+ toggleFormatters ( event : any ) {
67+ this . hasFormatters = event . detail . checked ;
68+ }
4369}
0 commit comments