Dynamic Row Moving on Preview Page

  • Last update:February 23, 2024
  • Overview

    Expected Effect

    You may want to adjust the order of the report according to your needs during the preview. In this case, you can move the current row by clicking the up and down buttons on the page, as shown in the following figure.

     开头.gif

    Implementation Method

    Define an array to store the sort order. When you click the up or down button, the values at the corresponding positions in the array will be exchanged. Then, you can sort the data according to this array.

    Example

    Dataset Creation

    Create a database query named ds1, and enter the SQL statement SELECT * FROM Sales_Volume.

     2.jpg

    Report Design

    Enter the formula &B2 in Cell A2, and set the left parent cell to B2. Set Data Setting of cell E2 to Summary-Sum and then hide column A. 

     3.jpg

    Dynamic Parameter Adding

    1. Select cell E2, add a dynamic parameter named a, and set the parameter value to the formula type, as shown in the following figure.

    let(arr, if(len($a) = 0, range(count(B2[!0;!0])), $a), let(idx, inarray(A2, arr), if(idx = 1, arr, maparray(arr, if(index = idx, indexofarray(arr, idx - 1), if(index = idx - 1, indexofarray(arr, idx), item)))))

     4.jpg

    2. Select cell F2, add a dynamic parameter named a, and set the parameter value to the formula type, as shown in the following figure. let(arr,if(len($a) = 0,range(count(B2[!0;!0])),$a),let(idx,inarray(A2,arr),if(idx = len(arr),arr,maparray(arr,if(index = idx,indexofarray(arr,idx + 1),if(index = idx + 1,indexofarray(arr,idx),item))))))

     5.jpg

    Formula description: Take the formula of cell E2 as an example.

    Formula

    Description

    let(arr,   if(len($a) = 0, range(count(B2[!0;!0])), $a), ……)

    Determines if array $a is empty. If so, expands a new array with the total number of rows in cell B2, otherwise, it is $a itself. Then assigns the final result to the variable arr.

    let(idx,inarray(A2,arr),……)

    Calculates the position of the value in cell A2 in the array arr and assigns the result to the variable idx.

    if(idx =   1,arr,maparray(arr,if(index = idx,indexofarray(arr,idx - 1),if(index = idx -   1,indexofarray(arr,idx),item))))

    If idx is equal to 1, arr is returned, which means that the order will not change when you click the first row. If idx is not equal to 1,  the value at the idx-th position in the arr array is replaced with the value at the idx-1 position, and the value at the idx-1 position is replaced with the value at the idx-th position.

    Sort After Expansion Setting

    Select cell B2 and set it to Sort After Expansion. Set Sort Basis to Formula and INARRAY(&B2,$a), and Sort Rule to Ascend.

     6.jpg

    Effect Display

    On PC

    Save the template and click Pagination Preview. The effect is the same as that shown in section "Expected Effect."

    On Mobile Terminals

    The preview effects on the DataAnalyst and HTML5 apps are the same, as shown in the following figure.

     结尾.gif

    Template Download

    You can download the template.Dynamic Row Moving on Preview Page.cpt


    Attachment List


    Theme: Report Application
    Already the First
    Already the Last
    • 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