Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update clipboard operations sample. #421

Merged
merged 10 commits into from
Oct 3, 2023
52 changes: 9 additions & 43 deletions samples/grids/grid/clipboard-operations/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,49 +17,15 @@
<div id="root">

<div class="container sample">
<div class="options vertical">
<igc-property-editor-panel
name="PropertyEditor"
id="PropertyEditor"
description-type="WebGrid"
is-horizontal="true"
is-wrapping-enabled="true">
<igc-property-editor-property-description
value-type="StringValue"
label="Change Copy Separator"
property-path="ClipboardOptions.Separator">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="ClipboardOptions.Enabled"
name="ClipboardEnabledEditor"
id="ClipboardEnabledEditor"
label="Grid Copy Behavior"
value-type="Boolean1"
primitive-value="True">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="ClipboardOptions.CopyHeaders"
name="ClipboardHeadersEditor"
id="ClipboardHeadersEditor"
label="Copying of Header Labels"
value-type="Boolean1"
primitive-value="True">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="ClipboardOptions.CopyFormatters"
name="ClipboardFormattersEditor"
id="ClipboardFormattersEditor"
label="Copying Column Formatters"
value-type="Boolean1"
primitive-value="True">
</igc-property-editor-property-description>
<igc-property-editor-property-description
value-type="Button"
primitive-value="Clear Selection"
name="propertyEditorPropertyDescription1"
id="propertyEditorPropertyDescription1">
</igc-property-editor-property-description>
</igc-property-editor-panel>
<div class="options horizontal" style="gap: 50px;">
<igc-input id="input">
<span slot="prefix">Change copy separator:</span>
<span slot="helper-text">The default value is a single tabulation.</span>
</igc-input>
<igc-switch id="copy" label-position="before" checked>Grid copy behavior</igc-switch>
<igc-switch id="headerCopy" label-position="before" checked>Copying of header labels</igc-switch>
<igc-switch id="formatterCopy" label-position="before" checked>Copying column formatters</igc-switch>
<igc-button id="selectionClear">Clear selection</igc-button>
HUSSAR-mtrela marked this conversation as resolved.
Show resolved Hide resolved
</div>

<div class="container fill">
Expand Down
68 changes: 27 additions & 41 deletions samples/grids/grid/clipboard-operations/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,48 @@
import { IgcPropertyEditorPanelModule } from 'igniteui-webcomponents-layouts';
import 'igniteui-webcomponents-grids/grids/combined';
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, WebGridDescriptionModule } from 'igniteui-webcomponents-core';
import { IgcPropertyEditorPanelComponent, IgcPropertyEditorPropertyDescriptionComponent } from 'igniteui-webcomponents-layouts';
import { IgcGridComponent } from 'igniteui-webcomponents-grids/grids';
import { NwindDataItem, NwindDataItem_LocationsItem, NwindData } from './NwindData';

import "igniteui-webcomponents-grids/grids/themes/light/bootstrap.css";
import 'igniteui-webcomponents/themes/light/bootstrap.css';
import { defineAllComponents } from 'igniteui-webcomponents';
import { ModuleManager } from 'igniteui-webcomponents-core';
import { defineAllComponents, IgcButtonComponent, IgcInputComponent, IgcSwitchComponent } from 'igniteui-webcomponents';
defineAllComponents();

ModuleManager.register(
IgcPropertyEditorPanelModule
);

export class Sample {

private propertyEditor: IgcPropertyEditorPanelComponent
private clipboardEnabledEditor: IgcPropertyEditorPropertyDescriptionComponent
private clipboardHeadersEditor: IgcPropertyEditorPropertyDescriptionComponent
private clipboardFormattersEditor: IgcPropertyEditorPropertyDescriptionComponent
private propertyEditorPropertyDescription1: IgcPropertyEditorPropertyDescriptionComponent
private grid: IgcGridComponent
private _bind: () => void;

constructor() {
var propertyEditor = this.propertyEditor = document.getElementById('PropertyEditor') as IgcPropertyEditorPanelComponent;
var clipboardEnabledEditor = this.clipboardEnabledEditor = document.getElementById('ClipboardEnabledEditor') as IgcPropertyEditorPropertyDescriptionComponent;
var clipboardHeadersEditor = this.clipboardHeadersEditor = document.getElementById('ClipboardHeadersEditor') as IgcPropertyEditorPropertyDescriptionComponent;
var clipboardFormattersEditor = this.clipboardFormattersEditor = document.getElementById('ClipboardFormattersEditor') as IgcPropertyEditorPropertyDescriptionComponent;
var propertyEditorPropertyDescription1 = this.propertyEditorPropertyDescription1 = document.getElementById('propertyEditorPropertyDescription1') as IgcPropertyEditorPropertyDescriptionComponent;
this.webGridClearSelection = this.webGridClearSelection.bind(this);
var grid = this.grid = document.getElementById('grid') as IgcGridComponent;
this.webGridClipboardOperationsColumnInit = this.webGridClipboardOperationsColumnInit.bind(this);

this._bind = () => {
propertyEditor.componentRenderer = this.renderer;
propertyEditor.target = this.grid;
propertyEditorPropertyDescription1.buttonClicked = this.webGridClearSelection;
grid.data = this.nwindData;
grid.addEventListener("columnInit", this.webGridClipboardOperationsColumnInit);

var copyBehaviorSwitch = document.getElementById("copy") as IgcSwitchComponent;
copyBehaviorSwitch.addEventListener("igcChange", (ev: CustomEvent) => {
grid.clipboardOptions.enabled = ev.detail;
});

var copyHeaderSwitch = document.getElementById("headerCopy") as IgcSwitchComponent;
copyHeaderSwitch.addEventListener("igcChange", (ev: CustomEvent) => {
grid.clipboardOptions.copyHeaders = ev.detail;
});

var formatterSwitch = document.getElementById("formatterCopy") as IgcSwitchComponent;
formatterSwitch.addEventListener("igcChange", (ev: CustomEvent) => {
grid.clipboardOptions.copyFormatters = ev.detail;
});

var selectionClearBtn = document.getElementById("selectionClear") as IgcButtonComponent;
selectionClearBtn.addEventListener('click', (ev: any) => {
grid.cellSelection = 'none';
grid.cellSelection = 'multiple';
});

var input = document.getElementById("input") as IgcInputComponent;
input.addEventListener("igcChange", (ev: CustomEvent) => {
grid.clipboardOptions.separator = ev.detail;
});
}
this._bind();

Expand All @@ -55,22 +57,6 @@ export class Sample {
return this._nwindData;
}

private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
PropertyEditorPanelDescriptionModule.register(context);
WebGridDescriptionModule.register(context);
}
return this._componentRenderer;
}

public webGridClearSelection(args: any): void {
console.log("TODO" + args);
//TODO
}

public webGridClipboardOperationsColumnInit(args: any): void {
let column = args.detail;
column.formatter = (e: any) => { return "** " + e + " **" };
Expand Down