Create Form Components with Kintone UI Component (v0)
Overview
This article introduces how to create Kintone's form components using the Kintone UI Component (v0) tool.
Attention
Kintone UI Component v0 has reached EOL. For the latest features and security support it is highly recommended upgrading to Kintone UI Component v1 .
For more details, refer to the End of Support Notice for Kintone UI Component v0 news.
What is Kintone UI Component (v0)?
Kintone UI Component (v0) is a library that allows Kintone developers to easily create Kintone-like user interfaces. Kintone-like components can be built using Kintone UI Component (v0), without the need to write extensive HTML, JavaScript, or CSS. This article goes through an example of building UI components, and also introduces some functions of Kintone UI Component (v0).
Example: Create Kintone-like Check boxes
Prepare the App
In this example, Kintone UI Component (v0) is used to create Check box components similar to Kintone's Check box field. Create an App with the following fields and settings.
Field Type | Field Name | Element ID |
---|---|---|
Blank space | - | component-UI |
Download Kintone UI Component (v0)
Follow these steps to download and apply Kintone UI Component (v0) to a Kintone App.
- Access https://github.com/kintone-labs/kintone-ui-component/releases
- Search for the latest v0 release. Download kintone-kintone-ui-component-0.x.tgz from the Assets, where 0.x is the version number.
- Unzip the downloaded tgz file.
- Locate the files kintone-ui-component.min.js and kintone-ui-component.min.css under package dist. Apply these files to the Kintone App through the JavaScript and CSS Customization Settings .
Sample Code
Use the following JavaScript code to display check-boxes with Kintone UI Component (v0). "component-UI" needs to be set as the Element ID of the Blank Space field where the check-box will be displayed.
|
|
In this example, the number of elements of the check box can be increased by adding elements to the items
on line 6.
Additionally, the default status of the check boxes can be changed by adding an items
element to value
on line 23. The element created may be handled as a DOM element by the component function render()
.
Available Methods
render()
Handles a created component as a DOM element.
|
|
addItem(item)
Adds an option to a check box component.
|
|
getItem(index), getItems()
Gets the options from a check box component.
|
|
removeItem(index)
Deletes the options from a check box component.
|
|
getValue(), setValue(value)
Gets or sets the value of a check box option.
|
|
disableItem(value), enableItem(value)
Disables or enables an option in the check box component.
|
|
on(eventName, callBack)
A callback function that is triggered when a specific event occurs for a component.
With check boxes, the eventName
parameter is specified as change
, which is an event that is triggered when the check boxes are checked or unchecked.
There are also similar on(eventName, callBack)
functions available for other components.
For example, with buttons the eventName
parameter is specified as click
, which is an event that is triggered when a button is clicked.
|
|
show(), hide()
Shows or hides the component.
|
|
disable(), enable()
Disables or enables the entire check box component.
|
|
Available UI Elements
Besides check boxes, Tables and other types of UI that cannot be implemented with 51-modern-default.css, can be added with Kintone UI Component (v0).
Table
|
|
There are various events available for the Table component:
rowAdd
Triggered when a row is added. The event object contains the value of the Table and the row number where the add button was clicked.
rowRemove
Triggered when a row is deleted. The event object contains the value of the Table.
cellChange
Triggered when the value of the cell is changed. The event object contains the value of the Table and the cell, as well as the position of the cell that is changed.
cellClick
Triggered when the cell is clicked. The event object contains the value of the Table and the cell, as well as the position of the cell that is clicked.
NotifyPopup
|
|
Pop-ups are easily implemented with NotifyPopup.
Spinner
|
|
A spinner that is displayed while the page is loading can also be implemented with Spinner.
IconButton
|
|
+, -, and x buttons can be created with IconButton.
Since the on()
method of IconButton has a click event, it is very simple to implement a function that runs when the button is clicked.