cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass information from list to view window?

heyo
Senior

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?

7 REPLIES 7
Yoann KLEIN
ST Employee

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 KLEIN
ST Software Developer | TouchGFX

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.

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 KLEIN
ST Software Developer | TouchGFX

@yoann KLEIN​  But how to do if I do not put container in view screen? Just putting elements from container in list.

0693W00000biQXMQA2_image.png

Then I think you have to use callbacks, please take a look at this article and this one.

/Yoann

Yoann KLEIN
ST Software Developer | TouchGFX

It can be used if in list layout is another list layout and in that list I need to pass index? I need to pass index from last list to view window

@yoann KLEIN​ 


_legacyfs_online_stmicro_images_0693W00000biUK7QAM.pngBut what to do if it's not added to view? Can you share a mini example to make me understand?