# Text wrap in Data Grids

**URL:** <https://forum.servoy.com/t/text-wrap-in-data-grids/20753>\
**Category:** Questions\
**Created:** [May 9, 2022, 2:10pm UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753 "2022-05-09T14:10:12Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![swingman](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/swingman/32/4536_2.png) [@swingman](https://forum.servoy.com/u/swingman)\
**Post date:** [May 9, 2022, 2:10pm UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/1 "2022-05-09T14:10:12Z")

</div>

Hi all,

I have been using the table component, but this does not appear to support non-continuous selection of records when the foundSet is set to multi-select.  
I can select records 2,3,4 but there does not seem to be any way to select just 2 and 4.  
The good thing about the table component, however, is that the row height will expand to ensure all the text of a cell fits.

So I decided to try the Data grid. It supports non-continuous selections, but the height of the rows is fixed, except if you construct some HTML with DIV’s set to display as blocks.  
Looking in the documentation for ag-grid there are two columns properties called ‘textWrap’ and ‘autoHeight’.  
If I try to add these to the columnDef of a Grid Column, servoy complains that these are not in the list of supported properties.

Is there any way around this?  
I need a list with variable row height that allows users to select more than one record that are not next to each other…

---

<div class="post-metadata">

**Author:** ![rph](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rph](https://forum.servoy.com/u/rph)\
**Post date:** [January 22, 2025, 10:51am UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/2 "2025-01-22T10:51:07Z")

</div>

Hi Christian

Did you ever found a solution for that? I have a similar situation here and also tried it with “autoHeight” and “wrapText” but without success.

Best, Roland

---

<div class="post-metadata">

**Author:** ![seain](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/seain/32/4511_2.png) [@seain](https://forum.servoy.com/u/seain)\
**Post date:** [January 22, 2025, 11:20am UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/3 "2025-01-22T11:20:27Z")

</div>

Has worked in our solution since at least 2024.03, maybe earlier (can’t remember).

Here’s a sample configuration:

[attachment=0]columnDefs.png[/attachment]

 ![columnDefs.png](https://canada1.discourse-cdn.com/flex010/uploads/servoy/original/2X/9/930ace03fc7d247829334460f836010acdb2c537.png)

---

<div class="post-metadata">

**Author:** ![Richard1521662995](https://avatars.discourse-cdn.com/v4/letter/r/8c91f0/32.png) [@Richard1521662995](https://forum.servoy.com/u/Richard1521662995)\
**Post date:** [January 22, 2025, 11:52am UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/4 "2025-01-22T11:52:22Z")

</div>

Hi Christian,

I use the NG Grid Services with one line of code plugins.ngDataGrid.columnOptions = { autoHeaderHeight: true, wrapHeaderText: true };

---

<div class="post-metadata">

**Author:** ![rph](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rph](https://forum.servoy.com/u/rph)\
**Post date:** [January 22, 2025, 3:46pm UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/5 "2025-01-22T15:46:33Z")

</div>

> seain:  
> Has worked in our solution since at least 2024.03, maybe earlier (can’t remember).
> 
> Here’s a sample configuration:
> 
> [attachment=0]columnDefs.png[/attachment]

Thanks for this answer. The “cellEditor”-Property in your example helped me a lot. I didn’t knew this one.

---

<div class="post-metadata">

**Author:** ![seain](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/seain/32/4511_2.png) [@seain](https://forum.servoy.com/u/seain)\
**Post date:** [January 23, 2025, 3:04am UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/6 "2025-01-23T03:04:37Z")

</div>

> rph:  
> Thanks for this answer. The “cellEditor”-Property in your example helped me a lot. I didn’t knew this one.

I’m not sure if it’s the answer to editing long text. The default maxLength is only 200 and since it’s bypassing Servoy’s [TextEditor](https://github.com/Servoy/aggridcomponents/blob/00636d9d92f3376cc153df030cdd6d2255bb6306/aggrid/projects/nggrids/src/editors/texteditor.ts) the maxLength of the column format won’t be applied. Setting the AGGrid property _columnDefs.cellEditorParams.maxLength_ also has no effect.

I find it strange that AGGrid’s Text Editor has a default length of 524288, but the Large Text Editor has a default of 200.

---

<div class="post-metadata">

**Author:** ![rph](https://avatars.discourse-cdn.com/v4/letter/r/c2a13f/32.png) [@rph](https://forum.servoy.com/u/rph)\
**Post date:** [January 23, 2025, 7:32am UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/7 "2025-01-23T07:32:11Z")

</div>

With the following JSON in “columnDef” I could enter 1’000 characters:

```auto
{
   "autoHeight": true,
   "cellEditorParams": {"maxLength": 1000},
   "cellEditor": "agLargeTextCellEditor",
   "wrapText": true
}

```

and also in the DataGrid it looks as I would expected it.

---

<div class="post-metadata">

**Author:** ![seain](https://yyz2.discourse-cdn.com/flex010/user_avatar/forum.servoy.com/seain/32/4511_2.png) [@seain](https://forum.servoy.com/u/seain)\
**Post date:** [January 24, 2025, 3:11am UTC](https://forum.servoy.com/t/text-wrap-in-data-grids/20753/8 "2025-01-24T03:11:26Z")

</div>

Thank you. I re-checked my setup and got it working. If it helps anyone, rather than manually updating all forms I’m running the following method in the onLoad of a generic parent form.

```auto
function applyDefaultColumnDefs(_oGrid) {
	_oGrid.columns.forEach(
		/** @param {CustomType<aggrid-groupingtable.column>} _col */
		function(_col) {
			if (_col.columnDef && _col.columnDef['cellEditor']) {
				// cellEditor = 'agLargeTextCellEditor'
				if (_col.columnDef.cellEditor.includes("agLargeTextCellEditor")) {
					if (!_col.columnDef['cellEditorParams']) {
						_col.columnDef['cellEditorParams'] = {};
					}
					
					// Only override if param not set. Could be defined at design-time.
					if (!_col.columnDef.cellEditorParams['maxLength']) {
						_col.columnDef.cellEditorParams.maxLength = 21845;
					}
				}
			}
		}
    );
}

```
