Load data on UI table/container expand

Hi, I’m working in Cuba 7.1

I currently have group table (initialized with data loader query) nested inside a VBox. Since the VBox is collapsed by default, I only want the data in the table to load when the user expands the VBox (when the table is visible to the user).

I’m wondering if there is some sort of built-in functionality that I could use to achieve this. I’ve looked for some sort of on-expand listener on the VBox, but I don’t think that exists. It would be great if there is a way to do what I described.

Thanks!

Hi @kuo.hong,

It is easier to help when you attach a test project or a code snippet. Either way, I’ll try to help with the information provided.

First, remove @LoadDataBeforeShow from your controller, and load screen data only when needed.

I’ll assume you are working with a GroupBox which can be collapsed or not. In the end of the documentation page, you can check the component API:

addExpandedStateChangeListener()

After implementing this listener in your controller, you’ll be able to add your logic to load the table only when the GroupBox contents are visible to the user.

Hope it helps.

Regards,
Peterson.

2 Likes

Thanks, that solves the issue! I was looking at the wrong UI component for the listener.