Hello all,
On my project I'm working on perspective and I want to build a dynamic table view, that renders based on some sort of tab navigation. My current setup (that I'm not sure is the best one) is I have a TabContainer and Table as a child of it. My goal is to render the tabs of the tab container onStartup event and when I click a tab, trigger "something" that renders the table. (I have a dataset tag auto-updating in the background that would be the data for the table). Each table has its own dataset tag, so I would need some sort of way to match the selected tab with the tag too.
So far, I have not been able to figure out how to trigger on a tab change event.
Am I overcomplicating this? Is there a better way to do this?
One Set of tabs, one table per tab, one dataset per table.
Bind the dataset to the expression now(5000)
(This runs the binding once every 5000ms) and in the script transform under it check if the current tab is open using an if statement pointing at the props.currentTabIndex
property of the tab container.
Then in that if statement run your query to update the dataset for the visible table.
This way you are only updating the visible data, and it changes if the tab changes.
Saves load on the database if multiple users open the page.
Yes.
Put a table in each tab, and bind each table to the relevant data source.
No scripting for this.
The tabs
property can take objects, not just strings, which allows you to set a runWhileHidden
boolean property for each tab. You don't need to manually handle the "stop refreshing when hidden" thing yourself.
2 Likes
Have you considered using a horizontal menu and a single table? Use the menu to affect what tag the table points to.
1 Like