How to add a rich text field and column

From InfiniteERP Wiki
Jump to: navigation, search

Introduction

This howto explains how to add a rich text field and column to the Openbravo system.

The steps to get a rich text field in your window consists of 2 steps: 1) add a column to a table, and 2) add a field to a tab.

You can also create a new table and a new window/tab ofcourse. These 2 steps are described in detail in the following howtos:

This howto will only focus on the specific part of a rich text field.

Bulbgraph.png   Rich text fields are available in MP20 and later MPs.

Example Module

This howto is supported by an example module which shows example of the code shown and discussed in this howto.

The example module adds a rich text field to the sales order header window. Please use an example module version of a release/implementation date of 23rd of January or later.

The code of the example module can be downloaded from this mercurial repository: https://code.openbravo.com/erp/mods/org.openbravo.client.application.examples/

Bulbgraph.png   The example module also contains implementations of other howtos.

Adding a column

First, you have to add a new column to the existing table.

Bulbgraph.png   As rich text is stored as HTML inside the database, the varchar column type should be used. What is more, the developer needs to keep in mind that 100 characters of rich text requires more that 100 chars of storage inside the database due to html markup. Usually, a factor of 2 will suffice, for example, if one wants to allow the user to enter 1000 characters of rich formatted text, the database column should have a type of varchar(2000).

When introducing the new column to the application dictionary, the correct reference must be selected, i.e. the new Rich Text reference:

Create a field - set col and rowspan

Then create a field within the tab/window. For a rich text field you can also set the col and rowspan (these are only shown when the corresponding column is defined as rich text):


The result

The result is visualized as a rich text editor in form view:



Bulbgraph.png   For now rich text fields can not be edited in grid mode (a hoover shows the content). They are always displayed as read-only fields.