Skip to content

Commit e11d06e

Browse files
committed
fix(igc-ts): grid templates correct component use and deps
1 parent f2e86d5 commit e11d06e

7 files changed

Lines changed: 141 additions & 263 deletions

File tree

packages/cli/templates/webcomponents/igc-ts/grid/default/files/src/app/__path__/__filePrefix__.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { describe, it, expect } from 'vitest';
22
import $(ClassName) from './$(path).js';
33

4-
describe('IgcDataGridComponent', () => {
4+
describe('IgcGridComponent', () => {
55
it('<app-$(path)> is an instance of $(ClassName)', async () => {
66
const element = document.createElement('app-$(path)');
77
expect(element).to.be.instanceOf($(ClassName));
Lines changed: 39 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,28 @@
11
import { 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)')
1710
export 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}</style>
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
}

packages/cli/templates/webcomponents/igc-ts/grid/default/index.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,7 @@ class IgcGridTemplate extends IgniteUIForWebComponentsTemplate {
1010
this.projectType = "igc-ts";
1111
this.name = "Grid";
1212
this.description = "IgcGrid with local data";
13-
this.packages = [
14-
"igniteui-webcomponents-core@~6.0.0",
15-
"igniteui-webcomponents-grids@~6.0.0",
16-
"igniteui-webcomponents-inputs@~6.0.0",
17-
"igniteui-webcomponents-layouts@~6.0.0"
18-
];
13+
this.packages = [ "igniteui-webcomponents-grids@~6.0.0" ];
1914
}
2015
}
2116
module.exports = new IgcGridTemplate();

0 commit comments

Comments
 (0)