How can I use domo.onFiltersUpdate to stop App refresh while still getting filtered data?
We have a Custom App on a dashboard with multiple filter cards. We like how the app responds to changes in the filters, but we would prefer it not have to refresh.
I found domo.onFiltersUpdate and see that the filter data is passed into the function for use in the event handler, but it's unclear how the filter data can be used to filter the app data the way it does without domo.onFiltersUpdate.
Does anyone know how domo.onFiltersUpdate is supposed to be used or if what I'm trying to do is even possible in Custom Apps using domo.js?
Answers
-
domo.onFiltersUpdate will run a function when the event happens. If you want nothing to happen then point it to a function that does nothing.
0 -
That's sort of the opposite of what I want. I want everything to happen except the refresh. I am able to use domo.onFiltersUpdate to run a function. I was hoping to use the filter data passed into my domo.onFiltersUpdate function when it gets called to make a call to load exactly the same filtered data the app would have loaded... just without the refresh.
0 -
Then have have your function do want you want instead of nothing. Have you reviewed the documentation for onFilterUpdate?
https://developer.domo.com/docs/dev-studio-guides/domo-js#domo.onDataUpdate
0 -
Yes. I was hoping there was more documentation somewhere to show how to use the filter data shown here in the results from the code example
https://developer.domo.com/docs/dev-studio-guides/domo-js#domo.onFiltersUpdate
to make a call to actually get the filtered data based on the filters selected, possibly in a manner similar to the filter options as shown here with the function to create filters
https://developer.domo.com/docs/dev-studio-guides/domo-js#domo.filterContainer.
To try to summarize, I want a way to get the data filtered based on the filters selected on the page. Domo does this automatically by default, but it causes the app to refresh. I still want the filtered data, but I want to avoid the refresh. I know about domo.onFiltersUpdate and that using it prevents the refresh. I also see from the documentation that data about the filters is passed to the function. The part I'm missing is how I can use that filter data to get my filtered data.
0 -
At the bottom of the filterContainer section it shows an example console log of what gets passed into the function you point to from onFilterUpdate. You can take the values you want from that object and put them into your array for the filterContainer.
0 -
I already have the filters I need on the page. It is my understanding from this documentation that domo.filterContainer creates a filter. I would instead like to make some kind of call to get data filtered based on the filters already existing on the page as the user makes changes to the filters.
0 -
Yes, so what you want to do is use the onFilterUpdate to capture the filters on the page and then in the function you call from onFilterUpdate pass the filters and values you want into the filterContainer which will then filter your data without the refresh.
0 -
It does not appear to work that way. filterContainer doesn't return any data. It creates filters on the page. Passing the data from onFilterUpdate into filterContainer doesn't appear to do anything, which makes sense - the filters already exist on the page exactly as passed, so recreating those same exact filters doesn't change anything.
I tried passing the filter data into domo.get as options and domo.post as body and also options to see if any of those would return the data filtered, but it does not appear to work that way. It seems as if domo.get and domo.post continue to get data as originally filtered based on how the filters were upon loading the app. Changing the filters does not appear to change the data they return.
0 -
Yeah sorry, I misspoke. So for the use case I was thinking of the filter app was just one card on a page of cards and in that case the other cards would filter. If you need the filtering in the same card it's a bit different.
When you use onFilterUpdate() this will catch the filter event and that will prevent your card from updating. This is the case even when using the filterContainer. That filter will get set but still gets caught by onFilterUpdate. If you want your app to also update with the filtered data but not do a full refresh you will have to handle the filters in the app itself (since you are capturing and preventing the normal filter event update which will cause a full refresh). What you need to do in this case is take the page filters that were captured and then convert those into queries for your data calls and then redo those calls to just update that part of your app.
Note: there is also currently an issue with the card details page that causes the filterContainer to not behave as expected. I'm working on getting that fixed but the page/dashboard view seems unaffected.
0 -
What you need to do in this case is take the page filters that were captured and then convert those into queries for your data calls and then redo those calls to just update that part of your app.
This is the part I was hoping to get a little more clarity on.
Firstly, when using domo.onFiltersUpdate, the call to domo.get/domo.post to get the data from the DataSet listed in the manifest returns data based on the filters as they were when the app first loaded, even if the call was made after changes to the page filters.
Secondly, I don't see an obvious way to make calls to get my data by passing in the filters as they come through domo.onFiltersUpdate. As you mentioned, I could write a bunch of custom code to translate those filters into queries, but this is not ideal for a number of reasons. The translation layer is not a trivial undertaking. It is error-prone as the filters don't map directly to queries. It is also brittle as any new filter we add to the page could require additional translation layer work.
I was hoping there was a way to pass the filters into a data retrieval function/API directly since Domo must already have the ability to translate filters into data queries - Domo does this automatically by default after all.
0 -
Unfortunately there currently is no way to drop the filter object into the queries and you would have to make a translation layer for them. The "automatic" way for filters to translate into the queries is the standard card behavior where the refresh happens.
0
Categories
- All Categories
- 1.7K Product Ideas
- 1.7K Ideas Exchange
- 1.5K Connect
- 1.2K Connectors
- 295 Workbench
- 6 Cloud Amplifier
- 8 Federated
- 2.8K Transform
- 97 SQL DataFlows
- 608 Datasets
- 2.1K Magic ETL
- 3.8K Visualize
- 2.4K Charting
- 709 Beast Mode
- 49 App Studio
- 39 Variables
- 667 Automate
- 170 Apps
- 446 APIs & Domo Developer
- 44 Workflows
- 7 DomoAI
- 33 Predict
- 13 Jupyter Workspaces
- 20 R & Python Tiles
- 391 Distribute
- 111 Domo Everywhere
- 274 Scheduled Reports
- 6 Software Integrations
- 115 Manage
- 112 Governance & Security
- Domo Community Gallery
- 31 Product Releases
- 9 Domo University
- 5.3K Community Forums
- 40 Getting Started
- 30 Community Member Introductions
- 103 Community Announcements
- 4.8K Archive