Implement a Vue.js Search Form in a Custom View
Overview
This article introduces how to implement Vue.js into a Custom View of a Kintone App. With this customization, records can be displayed dynamically with a search form. This article specifically uses Vue 3 for the implementation. For more information on Vue.js, refer to the official website:
Vue.js
The Customization Result
Kintone record data is displayed in the UI with Vue.js. The search form can be used to filter the displayed data.
App Setup
Create the form
Create a new App with the following field settings.
Field Type | Field Name | Field Code | Remarks |
---|---|---|---|
Text | Company Name | companyName | |
Link | Company Telephone Number | phoneNumber | Type set to Telephone number |
Prepare the library
Set the Vue.js library in the JavaScript and CSS settings of the App. For more information on Javascript and CSS settings, refer to the following article:
Customizing an App Using JavaScript and CSS
The Vue.js version used in this article is 3.4.31, and is obtained from the following CDN:
https://cdn.jsdelivr.net/npm/vue@3.4.31/dist/vue.global.min.js
Create a Custom View
In the App settings, navigate to the Views tab and click the [+] button to create a new View. For more information, refer to the following article:
Configuring Views
Give the view a name and select Custom view as the view type. Check Enable pagination and enter the following code into the HTML Code box. When complete, note the View ID and save the Custom View.
|
|
The HTML for the custom view features an input element for the search box, and an HTML table with the record field names for headers. The v-for
property and data enclosed in double curly brackets are syntaxes used by Vue.js. The array of records in event.records
are looped through using the v-for
loop, and adds each record's data to the table.
Sample Code
Prepare the following JavaScript code in a text editor and navigate to the Kintone App's settings. Upload the file into the Upload JavaScript for PC option of the JavaScript and CSS Customization settings.
Upload the following script to the App. Replace {ViewID} with the View ID of the Custom View. The View ID can be found in the Custom View settings.
sample.js
|
|
The default search function of Kintone only accepts full words. Implementing this customization with Vue.js allows the user to search incrementally.
Reference
Vue.js is suitable to easily create customized forms, displays, and other UI/UX dependent features in Kintone. Additionally, Computed properties and Components can be utilized to fulfill needs that Kintone may not be able to do by default, such as live updating of displayed data. There are also many other features of Vue.js that can be explored to create highly functional Kintone customizations. Try some out to see all the possibilities of Vue.js and Kintone.