Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion samples/grids/grid-lite/column-config-basic/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" />
<link rel="stylesheet" href="/src/index.css" type="text/css" />

</head>

Expand Down
5 changes: 2 additions & 3 deletions samples/grids/grid-lite/column-config-basic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
},
"dependencies": {
"babel-runtime": "^6.26.0",
"igniteui-webcomponents-core": "6.3.0-beta.0",
"igniteui-grid-lite": "latest",
"igniteui-webcomponents": "6.3.0-beta.0",
"igniteui-grid-lite": "^1.0.0-alpha.9",
"igniteui-webcomponents": "^6.3.1",
"lit-html": "^3.3.1",
"tslib": "^2.8.1"
},
Expand Down
29 changes: 29 additions & 0 deletions samples/grids/grid-lite/column-config-basic/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{
"compilerOptions": {
"noImplicitReturns": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"noImplicitAny": true,
"declarationDir": "dist/types",
"moduleResolution": "node",
"declaration": true,
"target": "es2015",
"module": "es2015",
"strict": true,
"strictNullChecks": false,
"baseUrl": ".",
"paths": {
"igniteui-webcomponents": [ "node_modules/igniteui-webcomponents"],
"igniteui-webcomponents-core": [ "node_modules/igniteui-webcomponents-core", "node_modules/@infragistics/igniteui-webcomponents-core" ],
"igniteui-webcomponents": [ "node_modules/igniteui-webcomponents", "node_modules/@infragistics/igniteui-webcomponents" ],
"igniteui-grid-lite": [ "node_modules/igniteui-grid-lite", "node_modules/@infragistics/igniteui-grid-lite" ]
}
},
"include": [
"src/**/*"
],
"exclude": [
"node_modules",
"dist"
]
}
15 changes: 14 additions & 1 deletion samples/grids/grid-lite/column-config-basic/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,19 @@ module.exports = env => {
template: 'index.html'
}),
new ForkTsCheckerWebpackPlugin()
]
],
devServer: {
client: {
overlay: {
runtimeErrors: (error) => {
if (error.message === 'ResizeObserver loop limit exceeded' ||
error.message === 'ResizeObserver loop completed with undelivered notifications.') {
return false;
}
return true;
},
},
},
}
};
};
103 changes: 81 additions & 22 deletions samples/grids/grid-lite/column-config-dynamic/index.html
Original file line number Diff line number Diff line change
@@ -1,28 +1,87 @@
<!DOCTYPE html>
<html>
<head>
<title>Grid Lite Dynamic Column Config | Ignite UI | Web Components</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" />
<link rel="stylesheet" href="/src/index.css" type="text/css" />
</head>

<body>
<div id="root">
<div class="container sample ig-typography">
<div class="controls-wrapper">
<button id="addColumn" class="sample-button">Add Column</button>
<button id="removeColumn" class="sample-button">Remove Last Column</button>
</div>
<div class="grid-lite-wrapper">
<igc-grid-lite id="grid-lite"></igc-grid-lite>
</div>
<head>
<title>Grid Lite Dynamic Column Config | Ignite UI | Web Components</title>
<meta charset="UTF-8" />
<link rel="shortcut icon" href="https://static.infragistics.com/xplatform/images/browsers/wc.png">
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel="stylesheet" href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" />
</head>

<body>
<div id="root">
<div class="container sample ig-typography">
<section id="panel">
<igc-dropdown id="dropdown" keep-open-on-select flip>
<igc-button slot="target" variant="outlined">Column properties</igc-button>
<igc-dropdown-item role="option" id="id">
<div class="config">
<span class="config-key">ID</span>
<igc-checkbox class="hidden-checkbox" label-position="before" checked>Hidden</igc-checkbox>
<igc-checkbox class="resizable-checkbox" label-position="before">Resizable</igc-checkbox>
<igc-checkbox class="filter-checkbox" label-position="before">Filter</igc-checkbox>
<igc-checkbox class="sort-checkbox" label-position="before">Sort</igc-checkbox>
</div>
</igc-dropdown-item>
<igc-dropdown-item role="option" id="name">
<div class="config">
<span class="config-key">Product Name</span>
<igc-checkbox class="hidden-checkbox" label-position="before">Hidden</igc-checkbox>
<igc-checkbox class="resizable-checkbox" label-position="before">Resizable</igc-checkbox>
<igc-checkbox class="filter-checkbox" label-position="before">Filter</igc-checkbox>
<igc-checkbox class="sort-checkbox" label-position="before">Sort</igc-checkbox>
</div>
</igc-dropdown-item>
<igc-dropdown-item role="option" id="price">
<div class="config">
<span class="config-key">Price</span>
<igc-checkbox class="hidden-checkbox" label-position="before">Hidden</igc-checkbox>
<igc-checkbox class="resizable-checkbox" label-position="before">Resizable</igc-checkbox>
<igc-checkbox class="filter-checkbox" label-position="before">Filter</igc-checkbox>
<igc-checkbox class="sort-checkbox" label-position="before">Sort</igc-checkbox>
</div>
</igc-dropdown-item>
<igc-dropdown-item role="option" id="sold">
<div class="config">
<span class="config-key">Units sold</span>
<igc-checkbox class="hidden-checkbox" label-position="before">Hidden</igc-checkbox>
<igc-checkbox class="resizable-checkbox" label-position="before">Resizable</igc-checkbox>
<igc-checkbox class="filter-checkbox" label-position="before">Filter</igc-checkbox>
<igc-checkbox class="sort-checkbox" label-position="before">Sort</igc-checkbox>
</div>
</igc-dropdown-item>
<igc-dropdown-item role="option" id="total">
<div class="config">
<span class="config-key">Total sold</span>
<igc-checkbox class="hidden-checkbox" label-position="before">Hidden</igc-checkbox>
<igc-checkbox class="resizable-checkbox" label-position="before">Resizable</igc-checkbox>
<igc-checkbox class="filter-checkbox" label-position="before">Filter</igc-checkbox>
<igc-checkbox class="sort-checkbox" label-position="before">Sort</igc-checkbox>
</div>
</igc-dropdown-item>
<igc-dropdown-item role="option" id="rating">
<div class="config">
<span class="config-key">Customer rating</span>
<igc-checkbox class="hidden-checkbox" label-position="before">Hidden</igc-checkbox>
<igc-checkbox class="resizable-checkbox" label-position="before">Resizable</igc-checkbox>
<igc-checkbox class="filter-checkbox" label-position="before">Filter</igc-checkbox>
<igc-checkbox class="sort-checkbox" label-position="before">Sort</igc-checkbox>
</div>
</igc-dropdown-item>
</igc-dropdown>
<igc-switch id="formattersSwitch" label-position="before" checked="true">Value formatters:</igc-switch>
</section>
<div class="grid-lite-wrapper">
<igc-grid-lite id="grid-lite"></igc-grid-lite>
</div>
</div>
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</div>
<% if (false) { %>
<script src="src/index.ts"></script>
<% } %>
</body>

</html>
5 changes: 2 additions & 3 deletions samples/grids/grid-lite/column-config-dynamic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
},
"dependencies": {
"babel-runtime": "^6.26.0",
"igniteui-webcomponents-core": "6.3.0-beta.0",
"igniteui-grid-lite": "latest",
"igniteui-webcomponents": "6.3.0-beta.0",
"igniteui-grid-lite": "^1.0.0-alpha.9",
"igniteui-webcomponents": "^6.3.1",
"lit-html": "^3.3.1",
"tslib": "^2.8.1"
},
Expand Down
34 changes: 22 additions & 12 deletions samples/grids/grid-lite/column-config-dynamic/src/index.css
Original file line number Diff line number Diff line change
@@ -1,20 +1,30 @@
.controls-wrapper {
margin-bottom: 1rem;
#panel {
margin: 1rem 0;
display: flex;
gap: 0.5rem;
flex-flow: row nowrap;
justify-content: space-between;
align-items: center;
}

.sample-button {
padding: 0.5rem 1rem;
cursor: pointer;
background-color: #007bff;
color: white;
border: none;
border-radius: 4px;
.config-key {
flex: 2 1 25% !important;
font-weight: bold;
}

.config {
display: flex;
flex-flow: row nowrap;
justify-content: space-evenly;
align-items: center;
gap: 0.75rem;
}

.sample-button:hover {
background-color: #0056b3;
.config * {
flex: 1;
}

igc-dropdown-item {
padding: 0.5rem 1rem;
}

.grid-lite-wrapper {
Expand Down
118 changes: 86 additions & 32 deletions samples/grids/grid-lite/column-config-dynamic/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,55 +1,109 @@
import { IgcGridLite } from 'igniteui-grid-lite';
import { GridLiteDataService, User } from './GridLiteDataService';
import { ColumnConfiguration, IgcGridLite } from 'igniteui-grid-lite';
import { defineComponents, IgcCheckboxChangeEventArgs, IgcCheckboxComponent, IgcDropdownComponent, IgcRatingComponent, IgcSwitchComponent } from 'igniteui-webcomponents';
import { GridLiteDataService, ProductInfo } from './GridLiteDataService';

import "igniteui-webcomponents/themes/light/bootstrap.css";
import "./index.css";

IgcGridLite.register();
defineComponents(IgcRatingComponent);
defineComponents(IgcDropdownComponent);
defineComponents(IgcSwitchComponent);
defineComponents(IgcCheckboxComponent);

const formatter = new Intl.NumberFormat('en-EN', {
style: 'currency',
currency: 'EUR',
});

export class Sample {
private dataService: GridLiteDataService;
private gridLite: any;
private dropdown: IgcDropdownComponent;
private formattersSwitch: IgcSwitchComponent;
protected hasFormatters = true;
protected format = (params: any) => formatter.format(params.value);
private columns: any[] = [];
private availableColumns = [
{ key: 'firstName', headerText: 'First Name' },
{ key: 'lastName', headerText: 'Last Name' },
{ key: 'age', headerText: 'Age', type: 'number' },
{ key: 'email', headerText: 'Email' },
{ key: 'priority', headerText: 'Priority' },
{ key: 'satisfaction', headerText: 'Satisfaction', type: 'number' }
];

constructor() {
this.dataService = new GridLiteDataService();
this.gridLite = document.getElementById('grid-lite') as any;
const data: User[] = this.dataService.generateUsers(50);

// Start with first two columns
this.gridLite = document.getElementById('grid-lite') as IgcGridLite<ProductInfo>;
this.dropdown = document.getElementById('dropdown') as IgcDropdownComponent;
this.formattersSwitch = document.getElementById('formattersSwitch') as IgcSwitchComponent;

const data: ProductInfo[] = this.dataService.generateProducts(50);

this.columns = [
this.availableColumns[0],
this.availableColumns[1]
{
key: 'id',
hidden: true,
headerText: 'ID'
},
{
key: 'name',
headerText: 'Product Name'
},
{
key: 'price',
headerText: 'Price',
type: 'number',
cellTemplate: (params: any) => {
const span = document.createElement('span');
span.textContent = formatter.format(params.value);
return span;
}
},
{
key: 'sold',
type: 'number',
headerText: 'Units sold'
},
{
key: 'total',
headerText: 'Total sold',
cellTemplate: (params: any) => {
const span = document.createElement('span');
span.textContent = formatter.format(params.value);
return span;
}
},
{
key: 'rating',
type: 'number',
headerText: 'Customer rating',
cellTemplate: (params: any) => {
const rating = document.createElement('igc-rating');
rating.setAttribute('readonly', '');
rating.setAttribute('step', '0.01');
rating.setAttribute('value', params.value.toString());
return rating;
}
}
];

this.gridLite.columns = this.columns;
this.gridLite.data = data;

// Setup button handlers
document.getElementById('addColumn')?.addEventListener('click', () => this.addColumn());
document.getElementById('removeColumn')?.addEventListener('click', () => this.removeColumn());
}

private addColumn() {
if (this.columns.length < this.availableColumns.length) {
this.columns.push(this.availableColumns[this.columns.length]);
this.gridLite.columns = [...this.columns];
}
}
this.dropdown.addEventListener('igcChange', (e: any) => { this.dropdown.clearSelection(); });
this.formattersSwitch.addEventListener('igcChange', (e: CustomEvent<IgcCheckboxChangeEventArgs>) => {
this.gridLite.updateColumns(
['price', 'total'].map((key) => ({
key,
cellTemplate: e.detail.checked ? this.format : undefined,
})) as ColumnConfiguration<ProductInfo>[]
);
});

private removeColumn() {
if (this.columns.length > 1) {
this.columns.pop();
this.gridLite.columns = [...this.columns];
}
document.addEventListener('click', (e: MouseEvent) => {
const target = e.target as HTMLElement;
if (target.tagName.toLowerCase() === 'igc-checkbox') {
const checkbox = target as IgcCheckboxComponent;
const dropdownItem = checkbox.closest('igc-dropdown-item');
const columnKey = dropdownItem?.id;
const prop = Array.from(checkbox.classList).filter(c => c.endsWith('-checkbox'))[0].split('-')[0];
this.gridLite.updateColumns({ key: columnKey, [prop]: !checkbox.checked });
}
});
}
}

Expand Down
Loading