Basically, if you don’t change a dataview query, it seems to stay the same until you reopen the query. It seems like currently, it doesn’t refresh the query even if the refresh interval is set, nor if you call the Force refresh command.
This is troublesome, when developing and testing queries, so I therefore ask if you know a way to trigger the query again, besides adding/removing space (or other insignificant changes to the query), and switching from/to reading view.
This is mostly a problem when the query is almost completely defined, but you change the base data for the query to test various cases, or you change fields that the query is based upon, but still the query itself is not changed.
And yes, I’ve tried asking at github, with no response for a few days. But I kind of remember seeing someone in this forum having a nifty little trick to trigger a query refresh, but I can’t find it. So therefore this request, if some of you know a way to trigger a rerun of a dataview query, when the query hasn’t changed, but some of the underlying data has.
Update: I forgot to mention that I usually have a dual setup with one tab in editing mode, and the other in reading mode. So the query to be refreshed is already in reading view.
Are you using a Dataview query language or a DataviewJS query? I’ve found that DQL queries usually refresh correctly when an underlying page changes, but sometimes DJS queries do not. I notice this regularly when I have a query that loads another script via dv.execute(await dv.io.load(...)).
Also, if you’re using indirect fields in a query (for example a value looked up from a page that is itself the result of another lookup), it seems like Dataview doesn’t always catch the change when the underlying page is updated.
I’ve found that switching between reading and edit mode doesn’t always force a refresh for DJS queries, but flipping back and forth from a previous page (e.g. using “Navigate Back” and “Navigate Forward”) does the trick.
That sounds like a neat trick, but I forgot to mention that I’m usually having a dual view setup, one tab with source mode and one with reading view, and of course that’s the one I would like to refresh.
I also do have indirect fields, and stuff like that, which makes it harder for dataview to pick up on any changes. I also use dataviewJS a lot. So I’m not making it easy for myself.
I’m a little divided on Datacore, it does sound intriguing to get a new tool like that, but I’m a little sad as that mean that Dataview is most likely going to get a whole lot less attention, and it might mean that in due time it gets to be yet another abandoned plugins. And there are far too many of them already, it seems.
You’re triggering the “Force reload” with that hotkey? That’s a little longwinded for my taste. I would really like to just get it to redo the query.
I’ve now found that if I add a button to change the first line to itself again, it will refresh the query. That is if the button changes the first line in the code block from ```dataview to ```dataview, it forces a refresh.
Typical code used to achieve this:
name To dataview
type line(19) text
Note that it does rely heavily on the line number of that first line, so if you change the text preceding the code block, be sure to also change the line number where it inserts the ```dataview text.
An image of the above code in use:
To turn on line numbers go to Settings > Editor > Show line numbers, and enable that.
Below is a larger showcase of how I use the same trick to also switch between a source view and the dataview view (even when in live preview or reading view).
Since this still is kind of a workaround, I’m leaving this post open for a proper and permanent refresh option of dataview queries.