Problems and solutions when submiting multi-value in drop-down checkbox

  • Last update:  2021-05-31
  • I. Overview

    1. Problem description

    When making a data entry template, it is often encountered that multiple indicators are checked in the cell widget, and the following two situations occur:

    1) When there is a primary key, the modification operation is performed, but only one value is retained after the submission is successful.

    For example:

    We checked the 4 indicators of "Jiajiale, Kangfu food, Miaosheng, and Weiquan" in the "drop-down checkbox" widget and submitted them to the database. After refreshing the page, we found that only the last selected indicator was retained.

    1.gif

    2) When the primary key does not exist, the add operation is performed. After the submission is successful, the database will store multiple data.

    For example:

    Use the "Product" table to add a piece of test data. After the supplier selects 3 indicators and submits it for storage, it is found that 3 new pieces of data have been added to the "Product" table.

    2.gif

    And we hope that after submitting multiple selection values in the "drop-down checkbox", multiple values can be displayed correctly in a piece of data. How to deal with it?


    2. Solution

    The return value type of the "drop-down checkbox" defaults to "Array". In the above two cases, the return value type needs to be "String", which leads to incorrect filling results.

    Method: Change the return value type of "drop-down checkbox" from "Array" to "String".

    Note: The solution for the modification operation and the addition operation is the same.

    II. Example

    1. Prepare template

    Open the built-in template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\Form\RowForm\Simple_Row-based_Form.cpt

    3.png


    2. Set drop-down checkbox widget

    Modify the D3 widget to "drop-down checkbox" widget, the return value type is "String", other defaults. The steps are shown in the figure below:

    4.png


    3. Set data dictionary

    Set the "Data Dictionary" to cell D3, set the type to "Database Table", select "FRDemo" for the database, select "Supplier" for the database table, the actual value is "SupplierID", and the display value is "Company_name". The steps are shown in the figure below:

    5.png


    4. Set formula form

    Select cell D3, set "Cell Attributes>Display>Formula Form", define the formula form: sql("FRDemo", "select DISTINCT Company_name from Supplier where SupplierID in (" + $$$ + ")", 1)

    The steps are shown in the figure below:

    6.png

    Note: The formula sql("FRDemo", "select DISTINCT Company_name from Supplier where SupplierID in (" + $$$ + ")", 1) makes the cell content displayed when the mouse leaves the cell display value instead of actual value.


    5. Modify field type

    The type of the "SupplierID" field in the designer's built-in database table "Product" is integer, and it needs to be modified to the text type before the string type value can be stored. Otherwise, an error will be prompted when submitting to the database: the data column type does not match.

    7.png


    6. Preview effect

    Save the template, click "Data Entry Preview", the effect is shown in the following figure:

    8.gif

    Note: Both App and H5 are supported.

    Note: The drop-down checkbox widget, radio button group widget, checkbox group widget and other multi-select widgets have similar problems, please refer to this document for handling.

    III. Download template

    Please refer to the completed template: %FR_HOME%\webapps\webroot\WEB-INF\reportlets\doc-EN\DataEntry\DataEntryApplication\Data_entry_mutiple-value.cpt

    Click to download: 

    Data_entry_multiple-value.cpt


    Attachment List


    Theme: Data Entry
    • Helpful
    • Not helpful
    • Only read

    滑鼠選中內容,快速回饋問題

    滑鼠選中存在疑惑的內容,即可快速回饋問題,我們將會跟進處理。

    不再提示

    10s後關閉

    Get
    Help
    Online Support
    Professional technical support is provided to quickly help you solve problems.
    Online support is available from 9:00-12:00 and 13:30-17:30 on weekdays.
    Page Feedback
    You can provide suggestions and feedback for the current web page.
    Pre-Sales Consultation
    Business Consultation
    Business: international@fanruan.com
    Support: support@fanruan.com
    Page Feedback
    *Problem Type
    Cannot be empty
    Problem Description
    0/1000
    Cannot be empty

    Submitted successfully

    Network busy