How to change the default query of records in smart views

Feature(s) impacted

Smart View

Observed behavior

records query all the entries in the database and there is no control over it.

Expected behavior

I want to change the default query for records and query based on some parameters. Is there any way to overwrite it?

Failure Logs

Context

  • Project name: Ourboro
  • Team name: Approval Team
  • Environment name: Development
  • Agent type & version: …
  • Recent changes made on your end if any: …

Hi @morekaccino :wave:

What would be the extent of your overwrite? What do you want to do? :clipboard:
Are you aware you can pass a filter object and pagination properties to store.query? :thinking:

Hi @anon37903635

Thank you for your response. I want to filter records based on the status field. I am aware that we can pass filters and other parameters when we are querying, but there is a default “records” variable in all smart views, and I want to overwrite its default query parameters. So when I open the smart view, instead of it showing me all the records, it only show me all the “Approved” records. It helps with the load time and makes pagination easier for me.

Thank you,

Hm… let me think about it :thinking:. There might be a couple of solutions: :memo:

:one: If you want absolutely this.args.records to be populated with an already filtered part of your collection, you can create a segment of your collection and then set the default display of it to your smart view.

:two: Trigger a fetchRecord/fetchData in the constructor of your smart view (or via the did-insert ember helper) with the proper filter and pagination settings. But with this one, you might want to manage a variable “locally” in your smart view.

Tell me if any of this helps :evergreen_tree: :muscle:

The first method is neat, Thanks!