How to Refresh Screens?

563 views
asked Dec 25, 2017 in GUI Development by Michalp
Hi!

I have a question:

How can I refresh the screen?

I have a screen that contains a Vertical List.

Every row contains an Action Button. The Action Button's OnClick opens a Dialog - the Dialog enable the user to edit the TextViews in the row.

The problem is that when the user edited the text and close the Dialog - the data he edit  - is not changed..

But if I get out from this screen and I entered again then I see the new data.

 

Besides, I have another problem like that:

On the first time I entered to the screen with the table - the default data appears and just when I exit and  enter again I see the new data.

 

Thanks,

Michal

2 Answers

+1 vote
answered Dec 25, 2017 by Christoph Friegel

Hi Michal,

check https://doc.embedded-wizard.de/vertical-list for "Force the list to reload items", which will lead you to InvalidateItems().

For your second issue, use the constructor init() to load your list right after initializing the class (with default values).
For example: Create a slot "initList" (that should load the list) and fire this slot in the init() via "postsignal initList".

Hope this helps,
Chris

commented Jan 9, 2018 by Christoph Friegel
My example was very simple. Un-zip it, open the ListExample and check the Init() and OnLoadItem() in Application::Application. This allows to create a list via device class with the correct data. Does this help?

If not:
Sorry, I cannot open your project (broken link).
You could send it to support@embedded-wizard.de.
Alternative: Provide some screenshots and code.
commented Jan 10, 2018 by Michalp

I attached you the screenshots and code.

Thanks.

I tried to send again the link. I hope it's good now.

https://ask.embedded-wizard.de/?qa=blob&qa_blobid=7685870255347738059

commented Jan 10, 2018 by Christoph Friegel

So, as far as I understand, you need a connection between "editing" and "refreshing". When you click on "edit" or "save" (afterwards), this should trigger the Refresh-slot, which reloads the list.

I would recommend...
- to add an "OnSave"-slot-Property (setter and getter can be deleted) to your EditChannel-Popup. 
- In your EditChannel-Popup you also need to create an save-slot that fires postsignal OnSave;
- Now add another "OnSave"-slot-Property (setter and getter can be deleted) to your ChannelsTableItem.
- When you click in your ChannelsTableItem on the edit button, I assume a slot will be fired, which opens a edit-popup. In this edit-slot connect the OnSave to the popup's OnSave. For example: popup.OnSave = OnSave.
- At last, go to Screens::Channel.OnLoadItem and add a itemView.OnSave = Refresh;

What is the plan, what does this do?
Channels contains the refresh-slot (which reloads the list) and gives it to the list items and the list items give the slot to the edit-popup. When you have edited a line and you click "save" this Refresh-slot will be fired and so the list reloads. Voila :-)

Overview:
List
-Refresh (slot)
-Items (object, that are connected via OnSave to Refresh)

Item
-OnSave (slot property)
-edit (slot, that opens the EditPopup and connects Item.OnSave to EditPopup.OnSave)

EditPopup
-OnSave (slot property)
-save (slot, that fires OnSave)


Hope this helps.
Chris

commented Jan 10, 2018 by Michalp
Thank you, but I don't know if you fully understood me...

I do have to refresh the list after editing, but I've already got along with it.
My problem is initialzing the screen. I want that on the first time you enter the screen to have the correct values ​​and not the default.
Will the solution you suggested help me reset the screen?

Thanks you very much,

Michal
commented Jan 10, 2018 by Christoph Friegel

My recommendation is just a good/common approach for the editing and refreshing part (because I couldn't see any solution on the screenshot this way).

For the other issue:
Whenever you initialize or reload your list onLoadItem is called. As far as I can see, in onLoadItem you access already via device class to the data (e.g. Data::Device.ChannelsCusName[itemNo]) and set it in the list. If you see at beginning the "wrong" (default) values, so I guess this is because this wrong values are stored in your device data (e.g. in ChannelsCusName array)?

0 votes
answered Jan 8, 2018 by Manfred Schweyer

Hi Michal,

as far as I understood your initialization problem, it is maybe more related to the data provider instead of the usage of the vertical list.

Once the vertical list is created, automatically the content is loaded.

Please ensure that the Data::Device contains a valid content and that the Data::Device object was not removed by the Garbage Collector. Please consider the livetime of autoobjects.

In order to prevent the Garbage Collector from freeing an autoobject, please add a variable to the root class, set the type to your class Data::Device and the value to the instance (autoobject) of the class. 

I hope this helps....

Best regards,

Manfred.

Ask Embedded Wizard

Welcome to the question and answer site for Embedded Wizard users and UI developers.

Ask your question and receive answers from the Embedded Wizard support team or from other members of the community!

Embedded Wizard Website | Privacy Policy | Imprint

...