11import { html , css , LitElement } from 'lit' ;
2- import { customElement } from 'lit/decorators.js' ;
3- import {
4- IgcDataGridModule ,
5- IgcGridColumnOptionsModule ,
6- IgcDataGridComponent ,
7- IgcColumnGroupDescription ,
8- } from 'igniteui-webcomponents-grids' ;
9- import { ModuleManager } from 'igniteui-webcomponents-core' ;
2+ import { customElement , state } from 'lit/decorators.js' ;
3+ import { IgcGridComponent , IgcGroupingExpression , SortingDirection } from 'igniteui-webcomponents-grids' ;
104
11- ModuleManager . register (
12- IgcDataGridModule ,
13- IgcGridColumnOptionsModule ,
14- ) ;
5+ import gridThemeLightMaterial from 'igniteui-webcomponents-grids/grids/themes/light/material.css?inline'
6+
7+ IgcGridComponent . register ( ) ;
158
169@customElement ( 'app-$(path)' )
1710export default class $ ( ClassName ) extends LitElement {
11+ static styles = css `
12+ : host {
13+ height: 100%;
14+ margin: 0px;
15+ padding- right: 20px;
16+ width: calc(100% - 600px);
17+ }
18+ igc- grid img {
19+ object-fit : contain;
20+ height : 100% ;
21+ width : 100% ;
22+ }
23+ ` ;
24+
25+ @state ( )
1826 data : any[ ] = [ {
1927 Country : 'USA' ,
2028 CountryFlag : 'https://static.infragistics.com/xplatform/images/flags/USA.png' ,
@@ -40,44 +48,29 @@ export default class $(ClassName) extends LitElement {
4048 Status : 'Packing' ,
4149 } ] ;
4250
43- static styles = css `
44- :host {
45- height: 100%;
46- margin: 0px;
47- padding-right: 20px;
48- width: calc(100% - 600px);
49- }
50- ` ;
51+ @state ( )
52+ groupingExpressions : IgcGroupingExpression [ ] = [
53+ { fieldName : 'status' , dir : SortingDirection . Desc } ,
54+ ] ;
5155
5256 render ( ) {
5357 return html `
54- < igc-data-grid
55- id =" grid "
56- height =" 100% "
57- width =" 100% "
58- auto-generate-columns =" false "
59- is-column-options-enabled =" true "
58+ < style > $ { gridThemeLightMaterial } < / s t y l e >
59+ < igc - grid
60+ class = "ig-typography "
61+ . data = $ { this . data }
62+ . groupingExpressions = $ { this . groupingExpressions }
63+ filter - mode = "excelStyleFilter "
6064 >
61- < igc-text-column field ="ProductID " header-text ="ID " width ="*>95 "> </ igc-text-column >
62- < igc-text-column field ="ProductName " header-text ="Product " width ="*>160 "> </ igc-text-column >
63- < igc-image-column field ="CountryFlag " header-text ="Country " width ="*>120 " contentOpacity ="1 "
64- padding-top ="5 " padding-bottom ="5 "> </ igc-image-column >
65- < igc-numeric-column field ="OrderItems " header-text ="Orders " width ="*>105 "> </ igc-numeric-column >
66- < igc-numeric-column field ="OrderValue " header-text ="Order Value " width ="*>140 " positive-prefix ="$ " show-grouping-separator ="true "> </ igc-numeric-column >
67- < igc-date-time-column field ="OrderDate " header-text ="Order Date " width ="*>135 " dateTimeFormat ="DateShort " > </ igc-date-time-column >
68- < igc-numeric-column field ="Margin " header-text ="Margin " width ="*>115 " positive-suffix ="% "> </ igc-numeric-column >
69- < igc-text-column field ="Status " header-text ="Status " width ="*>100 "> </ igc-text-column >
70- </ igc-data-grid >
65+ < igc - column field = "productID" header = "ID" width = "90px" > < / igc - column >
66+ < igc - column field = "productName" header = "Product" width = "160px" > < / igc - column >
67+ < igc - column field = "countryFlag" header = "Country" data - type = "image" width = "100px" > < / igc - column >
68+ < igc - column field = "orderItems" header = "Orders" data - type = "number" width = "100px" > < / igc - column >
69+ < igc - column field = "orderValue" header = "Order Value" data - type = "currency" width = "140px" > < / igc - column >
70+ < igc - column field = "orderDate" header = "Order Date" data - type = "date" > < / igc - column >
71+ < igc - column field = "margin" header = "Margin" data - type = "percent" width = "100px" > < / igc - column >
72+ < igc - column field = "status" header = "Status" width = "100px" groupable > < / igc - column >
73+ < / igc - grid >
7174 `;
7275 }
73-
74- firstUpdated ( ) {
75- const grid = this . shadowRoot ?. getElementById ( 'grid' ) as IgcDataGridComponent ;
76- grid . dataSource = this . data ;
77-
78- const grouping = new IgcColumnGroupDescription ( ) ;
79- grouping . field = 'Status' ;
80- grouping . displayName = 'Status' ;
81- grid . groupDescriptions . add ( grouping ) ;
82- }
8376}
0 commit comments