I have several objects on a perspective view (table, 2 xycharts) that all use the same underlying dataset, in this case, a Named Query. This particular view will be re-used on several pages with minor parameter value changes.
What is the best way to:
- Only have a single query occur to update all objects rather than each object rerunning the query.
- Update the objects when the underlying query changes. I have a tag that changes value whenever the database tables are updated. I thought about using a dataset tag but can’t seem to write to it in the tag change event script (“read only error”). Also the dataset could get large (1000+ rows). There is a polling option, but that would generate a lot of unnecessary querying if the system is idle.
All suggestions appreciated!! Thanks!
If all three use the same data:
- Supply Named Value query params as View params (
MyView.params.query_param_one /two /three, or as an object where each internal key is a param)
- Make a new property,
MyView.custom.data, which is bound to your Named Query and supplies the values you’re receiving from
- Bind the
props.data for each of your components to
In this way, the query is only being run once per View, instead of once per component.
Perfect!! Thanks for the quick reply.
Still getting use to the CUSTOM property feature - something that’s been wanted for a long time.
For the second part of that question:
How can I force the new data property to update other than by a poll rate? I do have a tag “DataTrigger” that increments whenever new data is available in the database.
A Named Query Binding should update whenever one of the supplied params changes, if memory serves me correctly.
You could also trigger manual refreshes of the query by using some Event to trigger a Script Action which then calls
self.view.refreshBinding("custom.data"), so just provide a Script Action to your trigger tag with the provided code. You shouldn’t ned to do anything to the components because the refresh of the Named Query should be picked up by the component bindings on
Sorry for the delayed response, your were correct about the update event on a parameter change.
Just finished coding an update of a view embedded in a view embedded in a carousel within a view that was tied to a menu tree selection. Parameter passing worked exactly as advertised!
Thanks for all the help!