Integrate Shared agGrid Cell Editors in Convertigo Pages

Convertigo Public Knowledge base

Integrate Shared agGrid Cell Editors in Convertigo Pages


๐Ÿ“Œ Overview

This article explains how to integrate shared agGrid cell editor components into Convertigo pages. It covers the use of shared components, class aliasing, and agGrid configuration for dynamic cell editing.

๐ŸŽฏ Use Case

You want to reuse custom cell editors across multiple Convertigo pages using agGrid. These editors are built as shared components and can be Convertigo Palette-based or HTML/CSS-based, depending on the context.

๐Ÿ› ๏ธ Prerequisites

  • Convertigo Studio installed

  • agGrid integrated into your Convertigo project

  • Shared components created and available under src/app/components

  • Basic knowledge of TypeScript and Angular component structure

๐Ÿงฉ Page Setup

๐Ÿ”น IonEditor Page

This page uses agGrid with two shared components:

  • IonTextEditor

  • IonListEditor

Both are built using Ionic components from the Convertigo palette.

๐Ÿ”น HtmlEditors Page

This page uses agGrid with the shared component:

  • HtmlListEditor

This component is composed of:

  • A Fragment for the HTML template

  • A Style for the CSS rules

๐Ÿ“ฆ Importing Shared Components

Each page must import the shared component class and create an alias for use in agGridโ€™s columnDefs.

Example: Import and Alias

/*Begin_c8o_PageImport*/ import { AgGridCellEditorsSample_HtmlListEditor } from "../../components/aggridcelleditorssample.htmllisteditor/aggridcelleditorssample-htmllisteditor"; /*End_c8o_PageImport*/ /*Begin_c8o_PageDeclaration*/ // htmlListEditor: alias to use as cellEditor in columnDefs public htmlListEditor : typeof AgGridCellEditorsSample_HtmlListEditor = AgGridCellEditorsSample_HtmlListEditor; /*End_c8o_PageDeclaration*/

Usage in agGrid

{ headerName: 'Customer*', field: 'customer', cellEditor: htmlListEditor, ... }

๐Ÿงฑ Component Structure

๐Ÿ”น Required Imports

/*Begin_c8o_CompImport*/ import { ICellEditorAngularComp } from 'ag-grid-angular'; import { ICellEditorParams } from 'ag-grid-community'; ... /*End_c8o_CompImport*/

๐Ÿ”น Component Declarations

/*Begin_c8o_CompDeclaration*/ params!: ICellEditorParams; items: CheckListItem[] = []; filteredItems: CheckListItem[] = []; searchText: string = ''; /*End_c8o_CompDeclaration*/

๐Ÿ”น Component Methods

/*Begin_c8o_CompFunction*/ agInit(params: ICellEditorParams): void { this.params = params; ... } getValue(): any { return this.items.filter(it => it.selected).map(it => it.value); } /*End_c8o_CompFunction*/

๐Ÿงฉ Creating a New Shared Component

To replicate the behavior of HtmlListEditor, create a new shared component named CheckboxSelectorEditor.

๐Ÿ”น Component Path

src/app/components/projectname.checkboxselectoreditor

๐Ÿ”น Generated Class Name

ProjectName_CheckboxSelectorEditor

Located in:

projectname-checkboxselectoreditor.ts

๐Ÿ”น Page Integration

Import the class and create an alias:

/*Begin_c8o_PageImport*/ import { ProjectName_CheckboxSelectorEditor } from "../../components/projectname.checkboxselectoreditor/projectname-checkboxselectoreditor"; /*End_c8o_PageImport*/ /*Begin_c8o_PageDeclaration*/ public checkboxSelectorEditor : typeof ProjectName_CheckboxSelectorEditor = ProjectName_CheckboxSelectorEditor; /*End_c8o_PageDeclaration*/

Use the alias in agGrid:

{ headerName: 'Options', field: 'options', cellEditor: checkboxSelectorEditor, ... }

ย 

Go get the sample demo project here: agGridCellEditorsSample


ย 

(c) Convertigo 2023 https://www.convertigo.com