Set default filter value

Hi,

It would be nice if you could set the default filter via code like the below screenshot. Currently when you open a list jig you don’t know what you are filtering on.

A solution is provided in Creating a default filter post.

Hi,

Yes I saw that post, however that only affects the datasource and not the UI.

@adam, agreed, I am logging a feature request to address the UI.

@adam the current behavior of the filter is to select the 1st tab by default.

In saying that, we have discovered a bug where it doesn’t select the 1st tab on a jig.default type specifically. It does work as expected on a jig.list type. Would it be possible for you to change to a jig.list?

Hi Elderi,

That’s not what I’m seeing.

Using a list jig you can see the below,

Upon clicking on the first tab, then it filters.

Here is the code.

title: Site Visit Requests
type: jig.list
icon: list

datasources:
  Jobs:
    type: datasource.sqlite
    options:
      provider: DATA_PROVIDER_LOCAL
      entities:
        - entity: jobs
      query: SELECT id, '$.jobId','$.title','$.assignedTo' FROM [jobs]
              WHERE '$.status' != 'Complete' AND ('$.assignedTo' LIKE @filter) 
      queryParameters:
        filter: =@ctx.jig.state.filter 

data: =@ctx.datasources.Jobs
filter:
  - title: My Jobs
    value: =@ctx.user.email
  - title: All Jobs
    value: "@"

item:
  type: component.list-item
  options:
    title: =@ctx.current.item.title

Hi Adam

I have good news and bad news :slight_smile:

Bad news:
You have unearthed another bug for us - an expression configured on a filter’s first tab does not get evaluated when a jig initializes.
Good news:
This has already been fixed in one of the upcoming releases.

For example, you can see here when I add =@ctx.jig.state.filter into the jig’s description that it returns with the expression itself as a string, and that’s why the filter does not select a tab.

Screenshot 2024-02-26 at 11.27.08 AM

Screenshot 2024-02-26 at 11.09.54 AM

I suggest as a workaround for now you can do one of two things:

  1. Use a static value as the email address (but probably not ideal), eg:
filter:
  - title: From Elderi
    value: elderi@jigx.com
  - title: All Msgs
    value: "@"
  1. Switch the 2 tabs so that the “All Jobs” tab is first and thus it will be selected by default, eg:
filter:
  - title: All Msgs
    value: "@"
  - title: From Elderi
    value: =@ctx.user.email

Elderi

Hi Elderi,

I’ll for the next release.

Thanks for the reply.

Adam.