68 views
in GUI Development by

Hi,

As we are using vertical list, we need to show (or) hide the menu items in the list based on the external status which varies for each menu item.

We are showing four menu items in a single page. All the menu items are static which is stored in a array. (database)

we are using a queue for maintaining the currently availble item's array index and loading the items with the requested array index in onloaditem.

for reference :

whole queue :

|   1     |                   
|   2     |
|   3     |
|   5     |
|   6     |
|   7     |
|   8     |
|   9     |
|   10   |

 

page currently in screen :

|   7     |
|   8     |
|   9     |
|   10   |

 

if item 10 is hided, 

the actual result is 

|   7     |
|   8     |
|   9     |

-empty-

the expected result is 

|   6     |
|   7     | 
|   8     |
|   9     |

 

first we are adjusting number of items, then calling invalidateitems(0, no_of_items-1), to load the whole list. In this case, In onloaditem 6th index is also getting loaded but once invalidate is completed. only 7,8 and 9 is visible. we are using scroll offset and adjusting this scenario.

number of items shown (or) hidden at the same time can differ. it will be within the array size. If 4 items are hided, and we are updating Vertical list number of items first, then we are calling invalidate_items, both times onload is getting triggered to reload the items. 

when onload item is triggered by the change in number of items, it is showing different item (because the list is shrinking), after a gap when invalidate is called then the expected screen is visible.

Also highlighter is maintained separately and ensure visibility is called to verify highlighted item is present in the screen. 

 

                                                                              

                                                        first onload                                                                                                      second onload

 

I have implemented it with some issues. for a clarification, is it possible to implement show/hide condition for menu items using vertical list. List view state updating, no of items updating and highlighter pointing all these sequences will be able to maintain in a order. Because when the update view state is calling onloaditem can't be determined by us. I have doubt in the vertical list sequence.

1 Answer

0 votes
by

Hello,

is it possible to implement show/hide condition for menu items using vertical list. List view state updating ...

No, the Vertical List is just a view to a content existing outside the list. To access the content the list uses OnLoadItem. There is no further intelligence implemented because the list itself does not store any data and does not track any states of the items.

Assuming there is a whole set of items and few of them are hidden, you could implement a 'filter' so the list 'sees' only the shown items from the entire set. For example, in your data base you could store with each item a flag 'hidden'. The OnLoadItem method, when accessing item X searches the content in your data base and skips over the items flagged with the state 'hidden'.

... no of items updating and highlighter pointing all these sequences will be able to maintain in a order. Because when the update view state is calling onloaditem can't be determined by us. I have doubt in the vertical list sequence.

This part of your question is not clear for me.

An alternative approach: from your question I have understood that you plan to create a menu system using Vertical List. This approach is fully legal. It is o.k. You could, however, create the  menu also using the Outline Box. The difference here is, the Outline Box maintains all contents (in this case the menu items) directly. There is no OnLoadItem mechanisms. If necessary, you can directly hide and resize the items. The Outline Box adjusts then all surrounding items automatically.

The advantage of the Vertical List is, it is optimized to deal with many (thousands) items. To achieve this, the list does not mainatin the items in the memory - it loads only the few actually visible items via OnLoadItem. Outline Box, in turn, maintains everything in memory. If the menus in your application are not too long (they are not composed of too many items), it could be worth to use Outline Box for this purpose. See also Outline Box.

Following this idea, Embedded Wizard provides a set of Menu component templates. These are intended to create your own menu systems. Internally the Menu component  templates use the Outline Box. See also Creating components from templates: Menu.

I hope it helps you further.

Best regards

Paul Banach

by
Hi Paul,

Thanks for the response. Like you said, we are using a flag to determine that the item is shown/hidden, so it will skip that array index and load next index in the list.

In runtime we will be changing number of items of vertical list dynamically. This number of items will be updated whenever there is a change in the number of items available. But when we will use invalidate_items() and reload the list is whenever there is change in the currently viewing page. (4 items in a page)

Some cases vertical list number of items will be updated, but that update won't affect the current screen. so list will not be reloaded.

As per sequence, first number of items will be updated, then if there is update currently visible screen, then the list will get reload.

But sometimes while updating number of items itself onload item is getting triggered, once this updated then a after a sec the invalidate_items() for reloading which is written is getting called. in this intermediate time I am getting redundant or empty screen. How does Vertical list process this change in number of items and invalidating.

How to overcome these scenarios and how to update the sequence. Is it mandatory to reload when number of items is getting changed. In between this updating highlighter position is also happening.

 

Thank you,

Meenakshi Sundaram S R.
by

Hi Meenakshi,

But sometimes while updating number of items itself onload item is getting triggered, once this updated then a after a sec the invalidate_items() for reloading which is written is getting called. in this intermediate time I am getting redundant or empty screen. How does Vertical list process this change in number of items and invalidating.

when the number of items grows, the list triggers OnLoadItem for all new items. Usually, you update first the data base containing the data of the items. Then you set the NoOfItems property to correspond to the current number of items. This will already ensure that the newly added items will be reloaded. If any of the other (old) items are also affected by the content alternation, perform also InvalidateItems() with the range of items affected by the alternation. 

How to overcome these scenarios and how to update the sequence. Is it mandatory to reload when number of items is getting changed. In between this updating highlighter position is also happening.

As mentioned above, when the number of items grows the new added items are automatically 'invalidated' and loaded. In all other cases, when the content of already existing items changes, the items need to be invalidated.

I hope it helps you further.

Best regards

Paul Banach

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

...