WebListBox.RowSelectionType ignored?

I am trying to create a WebListBox in which the user cannot select more than one row. No matter what I do, it seems to ignore my request. If I set the RowSelectionType to Single in the IDE editor, I can still select multiple rows. If I try to set it in the Opening event of the list box, same result. I even tried in the selection event to deselect all rows but the first, and that does nothing.

To reproduce, create a simple web app, put a ListBox in the window, set the RowSelectionType to Single in the IDE, put some code in the ListBox Opening event to populate the list box. When running, one can select multiple rows.

Am I missing something? If not, is there a workaround? (I am running 2022R1.1.)

I can’t find an Issues case for this, can you open one?

Case #68934, now marked as verified. I still have not found a workaround – any ideas?

Try this, in its Shown event:

Me.ExecuteJavaScript("$('#" + Me.ControlID + "_table').DataTable().select.style('single')")
1 Like

Thanks, Ricardo. I will try that.

1 Like

That works nicely. Thanks, Ricardo.

1 Like

Hmm. Ricardo’s solution works great the first time the page appears, but if I go to another page within the app and then return, the same listbox now allows multiple selections. I would have thought that once through the Javascript would do it, and/or that the “Shown” event would be fired each time the page reappears. Any idea why this is not working?

I just verified in the debugger that the “Shown” event for the WebListBox is not triggered when I return to the page from elsewhere in the app. Is this expected behavior or a bug? (It was not expected by me!)

what if you place the code in the opening event instead of the shown event?

I have just verified that if I put Ricardo’s code (with “me” changed to “MyListBoxName”) and put it instead in the “Shown” event of the WebContainer that holds the WebListBox, things work fine. But it still seems to me that the WebListBox’s “Shown” event should fire when the page is re-shown within the app. Is this a bug or am I missing something? The WebContainer’s “Shown” event is fired when the page is re-shown, why not the WebListBox’s?

Can you create a sample project? For an Issues case

OK, I have created a sample project. It turns out that the problem only occurs if the listbox is inside a container control: if the list box is sitting in a normal window, everything is fine. So is this a bug or is this something I am missing about how container controls work?

Test app to display the problem

It looks like the file is not public.
First the link asked if we are part of Pomona College, selecting not part of college it asks for login/password for a Box account.

Thanks, Alberto, for catching this. This was my error. Try the following link instead:

Public link to demonstration app

You can use that to create a case in Issues.
It seems not limited to WebListbox in Containers but other controls too.

Now posted to Issues: case 69062. The version of the app that I posted there illustrates that it also applies to textfields at least, so I think you are right, Alberto.

2 Likes