cancel
Showing results for 
Search instead for 
Did you mean: 
intapiuser
Community Team Member
Community Team Member

Challenge:

When making a BloX widget, there is no UI element that you can use to sort the widget.

Solution:

This custom BloX action allows you to trigger a sort for any widgets including itself.

Steps To Implement:

STEP 1A: CREATING THE ACTION

Create the action using the following code and name it "sort value"
var widgetIds = payload.data.widgetToSort
var valueIndexToSort = payload.data.valueIndexToSort
var sortOrder = payload.data.sortDirection
payload.widget.dashboard.widgets.$$widgets
    .filter(i => widgetIds.includes(i.oid))
    .forEach(function (widget) {
        // delete all sorts
        widget.metadata.panels[1].items.forEach(function (i) {
            if (i.jaql.hasOwnProperty('sort')) {
                delete i.jaql.sort
            }
        })
        // add new sort
        widget.metadata.panels[1].items[valueIndexToSort].jaql.sort = sortOrder
        widget.changesMade()
        widget.refresh()
    })

STEP 1B: CREATING THE ACTION SNIPPET

In Step 2 of 2 Create Action Snippet add the following snippet:
{
    "type": "sort value",
    "title": "sort",
    "data": {
        "widgetToSort": "enter ID here",
        "sortDirection": "choose desc/asc",
        "valueIndexToSort": "0"
    }
}

STEP 2: IMPLEMENTING THE ACTION

In the example gif, the clickable element was used. You can find it in the action snippets.
You can also use this action in a standard action button.
Here is the code for the clickable element:
{
   "type": "TextBlock",
   "text": "⬆",
   "selectAction": {
      "type": "sort value",
      "title": "sort",
      "data": {
         "widgetToSort": "5f1a0895fb660605bcc72a3a",
         "sortDirection": "asc",
         "valueIndexToSort": "0"
      }
   }
}
Version history
Last update:
‎03-02-2023 08:31 AM
Updated by:
Contributors
Community Toolbox

Recommended quick links to assist you in optimizing your community experience:

Developers Group:

Product Feedback Forum:

Need additional support?:

Submit a Support Request

The Legal Stuff

Have a question about the Sisense Community?

Email [email protected]

Share this page: