Special Multi-column Sort

  • Last update:  2024-02-21
  • Overview

    Application Scenario

    Based on the effect of the multi-column sort, the report block of the dashboard can sort data in descending, ascending, and unsorted order respectively when you click the column header for consecutive three times. The following figure shows the effect.

     1.gif

    Implementation Method

    You can achieve the effect of the special multi-column sort by using the Sort After Expansion and the Hyperlink (JavaScript type) functions. Three parameters, which can help you to achieve the effect in this document, exist in JavaScript.

    Parameter a: marks the ascending/descending order.

    Parameter b: marks the current field.

    Parameter c: marks the last click.

    Example

    Table Design

    1. Create a blank dashboard and create a dataset named ds1. The SQL statement is SELECT * FROM ORDERS limit 20.

    2. Drag a report block named report0 (that must be consistent with the one used in the following JavaScript codes) into the body of the dashboard. Design the table of the report block, as shown in the following figure.

     2.png

    Sort After Expansion Setting

    Select cell A2 and set Sort Basis to Formula and switch($a,0,"",1,eval($c)*-1,2,eval($c)) and Sort Rule to Ascend in Sort After Expansion.

     3.png

    JavaScript Hyperlink Setting

    Select cell B1, add a hyperlink, select JavaScript from the drop-down list, add three parameters, and enter JavaScript codes, as shown in the following figure.

     4.png

    The following table describes the added parameters.

    Parameter
    TypeValue

    a

    Formula

    $a

    b

    Character String

    b2

    c

    Formula

    $b

    JavaScript codes are as follows:

    if(a==null||b!=c||a.length==0)
    {
    _g().getWidgetByName("report0").gotoPage(1, {a:1,b:b,c:b}, true)
    }
    if(a==1&&b==c)
    {
    _g().getWidgetByName("report0").gotoPage(1, {a:2,b:b,c:c}, true)
    }
    if(a==2&&b==c)
    {
    _g().getWidgetByName("report0").gotoPage(1, {a:'',b:b,c:c}, true)
    }

    iconNote:
    Remember to modify the name of the report block in the code when you apply the template.

    After finishing the setting of cell B1, set similar hyperlinks for cell C1, cell D1, cell E1, and cell F1, for which the values of parameters a and c are the same as those of cell B1.

    The values of parameter b in the JavaScript hyperlink for cell C1, cell D1, cell E1, and cell F1 are c2, d2, e2, and f2 respectively.

     5.png

    The following figure shows the final table result.

     6.png

    Effect Display

    Save the template and click PC Preview. The effect is shown in section "Application Scenario."

    The template can be previewed on the DataAnalyst and HTML5 apps.

    Template Download

    You can download the example template Special Multi-column Sort.frm.


    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