Skip to main content
heyo
Associate III
April 19, 2023
Question

How to pass information from list to view window?

  • April 19, 2023
  • 7 replies
  • 2295 views

I've created list in my view window:


_legacyfs_online_stmicro_images_0693W00000biNTgQAM.pngand by add new date I create elements in list. My custom container looks like that:


_legacyfs_online_stmicro_images_0693W00000biNTqQAM.pngWhen I click plus button it calls this function:


_legacyfs_online_stmicro_images_0693W00000biNU5QAM.pngHow u see there is ProfileCount++; variable and I need to pass that value in to my view window. I ve tried to create object and by function pass index to my view but simulator always crashes when i do that. So maybe someone knows how to pass information from list elements?

This topic has been closed for replies.

7 replies

Yoann KLEIN
ST Employee
April 19, 2023

Hello @heyo​,

When trying to share a variable between different screens, I'll suggest to use the Model-View-Presenter pattern. Please take a look at this article to learn on how to propagate data between those layers.

Here, I think that you could send the ProfileCount variable to the Model from your Container, and then read this value from your view.

/Yoann

Yoann KLEINST Software Developer | TouchGFX
heyo
heyoAuthor
Associate III
April 19, 2023

Hello @Yoann KLEIN​ 

But if I want to pass that value to model I need to pass it to my view screen, and I don't know how to pass it from list, cause I've creating list by clicking plus button. I've tried to create an object of class and pass it by function but simulator crashes, also I've tried to point to my view window and also crashes.

Yoann KLEIN
ST Employee
April 19, 2023

If you want to pass a variable from a custom container its parent view, you can see how it is done in the Custom Trigger Action Example available in TouchGFXDesigner.

There you'll see how to use triggers with parameters in Custom Containers and how to retrieve these parameters in the main view.

/Yoann

Yoann KLEINST Software Developer | TouchGFX