Add runtime sorting by passing parameter URL

Hi Helical Team,

I am using open source BI Helical Insight version 5.2.3. I have created a tabular report and would like to enable column sorting only at runtime when the report is being viewed.

That means:

I don’t want to apply any default sorting while creating the report (neither through the UI nor through SQL).

But at runtime (read/view mode), I want the user to be able to sort the report by clicking a specific column or by specifying sorting in the URL.

Is this possible in Helical Insight 5.2.3? If yes, how can I achieve it?

Thanks.

Hi,

Yes, this is possible in Helical Insight 5.2.3 by using the Custom Operations feature. Specifically, you can inject custom JavaScript code in the “Pre Execution” section of the report to achieve runtime sorting behavior.

Here’s how to implement it:

Step-by-Step Solution

  1. Open the report in report edit mode.

  2. Go to the Customize > Operations section.

  3. Select “Pre Execution” tab.

  4. Paste the following custom JS code:

image

var tempBaseUrl = new URLSearchParams(window.location.href.split('?')[1]);

var sortColumn = tempBaseUrl.get('sort_column');

var sortCond = tempBaseUrl.get('sort_condition');

if (sortCond) {
    sortCond = sortCond.replace(/['"]/g, '').toLowerCase();
}

if (!['asc', 'desc'].includes(sortCond)) {
    sortCond = 'asc';
}

if (sortColumn != null && sortColumn.trim() !== '') {
    if (properties.table.hasOwnProperty(sortColumn)) {
        if (!properties.table[sortColumn].includes('sort')) {
            properties.table[sortColumn].push('sort');
        }
    }

    fields.map(item => {
        if (item.hasOwnProperty('alias')) {
            if (item.alias == sortColumn) {
                item.orderBy = [sortCond];
            } else if (item.autogen_alias == sortColumn) {
                item.orderBy = [sortCond];
            }
        } else {
            if (item.autogen_alias == sortColumn) {
                item.orderBy = [sortCond];
            }
        }
    });
}

Usage Example

Your report URL should look like this:

https://<your-server-ip>:8443/hi-ee/#/report-viewer?dir=<directory>&file=<report-name>.hr&mode=open&sort_column=employee_name &**sort_condition=asc**

Replace:

sort_column with the alias or autogen_alias of your target column

sort_condition with either asc or desc

This will sort the specified column in the given order only at runtime, without applying any static sorting during report creation.

Let us know if you need help with identifying the correct column alias or implementing this in a different context!

Thank You,
Helical Insight.