You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The ability to customize cell editing UI has been the most demanded feature for TOAST UI Grid for a long time. Users used to use the formatter for this purpose, but the formatter is aimed to customize the contents of the cell, not to customize editing UI.
With the release of version 4, the official Cell Editor interface is supported by default in the TOAST UI Grid so that users can customize the editing UI to meet their own requirements.
CellEditor Interface
The CellEditor should be the constructor function. The TOAST UI Grid will make instances of it using new keyword internally. We recommend using class keyword, but in case class keyword is not available, function and prototype can be used instead.
The CellEditor should implement the interface below.
This method should return the root DOM element of the editor. When editing is started, the returned element will be appended to the editing layer DOM.
getValue()
This method should return the value of the cell. When editing is finished, the returned value will be used to set the cell value.
mounted()
This method is an optional, and can be used to initialize Input elements. This method is invoked right after the root element returned by getElement() is attached to the DOM.
beforeDestroy()
This method is an optional, and can be used to clean up input elements. This method is invoked right before the root element returned by getElement() is detached from the DOM.
Example
The following is the source code of the simple text editor.
The constructor function is invoked whenever editing is started. It's common to store the root element as an instance member, so that it can be used later in other methods such as getElement() and getValue().
The constructor function receives props object which contains useful information for customizing editing UI. The interface of the props object is like below.
The grid property is an instance of TOAST UI Grid itself. This can be useful if you want to get specific data or manipulate the data manually.
The columnInfo property contains the all information of the column in which the target cell is contained. The inerface of the ColumnInfo is like below.
Note that editorOptions.listItems property is used for the checkbox editor. The checkbox, radio, select editor will use this data when displaying list items.
Custom Editors
You can register your own editor also. For this, the constructor function should be set to the editor property of the columns options.
Note that you can define your own editorOptions and use it in the constructor function using props.columnInfo.editorOptions.
Feedback Welcome!
The TOAST UI Grid 4 is still in progress and plainning to release the official version by middle of June. If you are a passionate user of the TOAST UI Grid, please give the alpha version of V4 a try and give us some feedback about this specification. Thanks!!
The text was updated successfully, but these errors were encountered:
Cell Editor
Intro
The ability to customize cell editing UI has been the most demanded feature for TOAST UI Grid for a long time. Users used to use the formatter for this purpose, but the formatter is aimed to customize the contents of the cell, not to customize editing UI.
With the release of version 4, the official Cell Editor interface is supported by default in the TOAST UI Grid so that users can customize the editing UI to meet their own requirements.
CellEditor Interface
The
CellEditor
should be the constructor function. The TOAST UI Grid will make instances of it usingnew
keyword internally. We recommend usingclass
keyword, but in caseclass
keyword is not available,function
andprototype
can be used instead.The
CellEditor
should implement the interface below.getElement()
This method should return the root DOM element of the editor. When editing is started, the returned element will be appended to the editing layer DOM.
getValue()
This method should return the value of the cell. When editing is finished, the returned value will be used to set the cell value.
mounted()
This method is an optional, and can be used to initialize Input elements. This method is invoked right after the root element returned by
getElement()
is attached to the DOM.beforeDestroy()
This method is an optional, and can be used to clean up input elements. This method is invoked right before the root element returned by
getElement()
is detached from the DOM.Example
The following is the source code of the simple text editor.
The constructor function is invoked whenever editing is started. It's common to store the root element as an instance member, so that it can be used later in other methods such as
getElement()
andgetValue()
.The constructor function receives props object which contains useful information for customizing editing UI. The interface of the props object is like below.
The
grid
property is an instance of TOAST UI Grid itself. This can be useful if you want to get specific data or manipulate the data manually.The
columnInfo
property contains the all information of the column in which the target cell is contained. The inerface of theColumnInfo
is like below.More information of every properties will be specified in the official document. Before that, please refer to the source code of store/dyptes.ts file.
Usage
Built-in Editors
Currently, 5 built-in editors are supported by default.
<input type="text" />
<input type="password" />
<input type="checkbox" />
and<label>
<input type="radio" />
and<label>
<select>
and<options>
For using these built-in editors, you can use
string
value for theeditor
property of thecolumns
options.Note that
editorOptions.listItems
property is used for thecheckbox
editor. Thecheckbox
,radio
,select
editor will use this data when displaying list items.Custom Editors
You can register your own editor also. For this, the constructor function should be set to the
editor
property of thecolumns
options.Note that you can define your own
editorOptions
and use it in the constructor function usingprops.columnInfo.editorOptions
.Feedback Welcome!
The TOAST UI Grid 4 is still in progress and plainning to release the official version by middle of June. If you are a passionate user of the TOAST UI Grid, please give the alpha version of V4 a try and give us some feedback about this specification. Thanks!!
The text was updated successfully, but these errors were encountered: