Textarea Editor
This editor is a custom cell editor for RevoGrid that allows users to handle multi-line text input, making it suitable for applications requiring rich text editing capabilities within grid cells.
To move to the next line within the TextAreaEditor
, the user should press Shift + Enter
.
Source code
import { defineCustomElements } from '@revolist/revogrid/loader';import { TextAreaEditor } from '@revolist/revogrid-pro';
defineCustomElements();
export function load(parentSelector: string) { const grid = document.createElement('revo-grid'); grid.range = true; grid.rowSize = 60;
grid.source = [ { name: `John Doe `, }, ];
grid.columns = [ { prop: 'name', editor: 'textarea', cellProperties: () => ({ style: { 'white-space': 'pre' } }), }, ];
grid.editors = { textarea: TextAreaEditor, };
grid.theme = 'compact'; grid.hideAttribution = true;
document.querySelector(parentSelector)?.appendChild(grid);}
<template> <div class="not-content"> <RevoGrid hide-attribution range :editors="editors" :rowSize="60" :source="source" :columns="columns" :plugins="[ColumnStretchPlugin]" :additionalData="{ stretch: 'all' }" :theme="isDark ? 'darkCompact' : 'compact'" /> </div></template>
<script setup lang="ts">import RevoGrid, { type ColumnRegular, type Editors } from '@revolist/vue3-datagrid';import { TextAreaEditor, ColumnStretchPlugin } from '@revolist/revogrid-pro';import { ref } from 'vue';import { currentThemeVue } from '../composables/useRandomData';
const { isDark } = currentThemeVue();
const source = ref([ { name: `John Doe `, },]);
const editors: Editors = { textarea: TextAreaEditor,};const columns: ColumnRegular[] = [ { prop: 'name', editor: 'textarea', cellProperties: () => ({ style: { 'white-space': 'pre' } }), },];</script>
import React, { useMemo } from 'react';import { RevoGrid, type ColumnRegular } from '@revolist/react-datagrid';import { TextAreaEditor } from '@revolist/revogrid-pro';import { currentTheme } from '../composables/useRandomData';
const { isDark } = currentTheme();
function EditorTextarea() { const source = [ { name: `John Doe `, }, ];
const columns: ColumnRegular[] = useMemo( () => [ { prop: 'name', editor: 'textarea', cellProperties: () => ({ style: { 'white-space': 'pre' } }), }, ], [], );
const editors = { textarea: TextAreaEditor, };
return ( <div> <RevoGrid range rowSize={60} columns={columns} source={source} editors={editors} theme={isDark() ? 'darkCompact' : 'compact'} hideAttribution /> </div> );}
export default EditorTextarea;
import { Component, ViewEncapsulation } from '@angular/core';import { RevoGrid } from '@revolist/angular-datagrid';import { TextAreaEditor } from '@revolist/revogrid-pro';import { currentTheme } from '../composables/useRandomData';
@Component({ selector: 'editor-textarea-grid', standalone: true, imports: [RevoGrid], template: ` <revo-grid [range]="true" [rowSize]="60" [columns]="columns" [source]="source" [editors]="editors" [theme]="theme" [hideAttribution]="true" style="height: 400px;" ></revo-grid> `, encapsulation: ViewEncapsulation.None,})export class EditorTextareaGridComponent { source = [ { name: `John Doe `, }, ];
columns = [ { prop: 'name', editor: 'textarea', cellProperties: () => ({ style: { 'white-space': 'pre' } }), }, ];
editors = { textarea: TextAreaEditor, };
theme = currentTheme().isDark() ? 'darkCompact' : 'compact';}