This thread was migrated from an old forum. It may contain information that are no longer valid. For further assistance, please post a new question or open a support ticket from the Customer Support portal.
Currently I use the following code to set the data in a listbox:
with selection being a valid key of master data. AFAIK this should mean that the listbox is shown with element represented by selection to be selected.
So what could go wrong? What caveats exists with the use of listboxes?
We have to use selectedKey instead of selectedKeys for showing the pre-selected item in listbox.
var dat = [["key1","Kony"],["key2","India"],["key2","Private"]]; this.view.lstbox123.masterData = dat; this.view.lstbox123.selectedKey = "key2";//dat[2][0]
@Kvwen Cvmewon I tried selectedKey as well. In fact, I tried selectedKey first and only move to selectedKeys when it did not work. They both don't work. There must be something else here.
I have checked in 8.1.7 version of Kony Enterprise for the code and it working fine. Can you please let us know about the plugins you are using and also the platform in which you are checking.
I will check accordingly. If possible can you please share the sample app you are working on so that I will also debug and can come to a solution.
Put I don't think this is an bug be replicate. This is why I asked for caveats. Well known pitfalls one can do wrong when using selectedKey. Stuff to look out for. Because I am pretty sure it works when you do everything just the right way.
Please call in preShow of the form. It might be because of the hot fix plugins you are using currently. Please update to the latest GA version to avoid any issues.
Update for anybody who might find this: I used numeric keys starting with "0" and that seemed to be the problem on Android. If a different key, for example “2” is used it works.
The obvious workaround would be to add a character to the keys. For example "@0", "@1", …
A more obscure workaround is the use toString. For example «selectedKey = selection.toString()». That too works.
Both workarounds are tideous and error prone.
And to answer my original question on which caveat might exist:
DON'T USE NUMERIC KEYS STARTING WITH 0 — That does not work with Android.
@Jvne Dickens Just checking up on my tickets I noticed that the Ticket i wrote for this problem has been closed.
But this is clearly a bug which need to be fixed and that I had a workaround and and was on holiday and hence did not respond makes no difference to the fact that this is bug.
This bug needs to be fixed — not for me because I have a workaround — but for all your other customers who do not know about the workaround and can fall for the same problem.
You should not be satisfied with “closing a ticket” and “Selected as Best” the community posting.