Hide SmartGwt ComboboxItem if it has only one value to be selected - combobox

I am working with SmartGwt.
Is it possible to hide the combobox dropdown button if it has only one Item?

use the property like setShowPickerIcon(false), If we use this property, the SelectPicker Icon mean dropdown button will be invisible.

Add a change listener to it, if it has only one element, call setVisible(false).

Imho, it is not possible, but you can replace it with TextItem which has no dropdown button dynamically. Either by invoking setVisible(false/true) or by removing/adding it from/to the form.

Related

How to change the color of the cell dynamically after the ui grid is loaded

Searched Stack Overflow and Google a lot but cannot understand how to change the background color of a cell in ui grid after the grid is loaded with values.
For example after a button press I want to change background color on the cell.
You can use Rowtemplate and override ui-grid-cell. In the rowTemplate, you can add ng-click function and do whatever you want to do inside that function.
One more option to add an html for cellTemplate and add ng-class, based on conditions update class and have css for that class accordingly.

How to add CheckBoxes to a ComboBox?

I want to create a ComboBox having Checkboxes as children using Codename one.
I am not using the UIBuilder
For reusability I created a Container having three Checkboxes in it:
OverviewCheckBoxContainer
- Checkbox1
- Checkbox2
- Checkbox3
and this works already.
As it takes too much space on the screen, I now tried to add the CheckBoxContainer into a Combobox, like this:
ComboBox
- OverviewCheckBoxCont
-...
but it does not work, the ComboBox contains a single entry only and it's not a checkbox, but a text:
OverviewCheckBoxCont[x=...
(cannot see further on the screen)
How can I solve this issue, so there is a dropdown menu containing the three Checkboxes, that toggle onClick?
ps:
In the main form I added the CheckBoxesComboBox instead of the CheckBoxesCont:
this.add(BorderLayout.CENTER, checkBoxesComboBox)
instead of
this.add(BorderLayout.CENTER, checkBoxesCont)
1.You can use simple combobox as shown below
ArrayList al = new ArrayList();
findComboBox().setModel(new DefaultListModel(al));
2.And to add checkbox in combobox , you have to customize the combobox
3.Instead of customizing combobox, You can use button which shows and hides OverviewCheckBoxContainer which contains list of checkboxs
See this for customizing the ComboBox with the generic list cell renderer: https://www.codenameone.com/manual/components.html#_combobox
The problem with using checkboxes in a combo is that you would assume they would all appear in the combo as a set and the combo wasn't designed to do that. I would instead just use a Button and show a dialog with a set of checkboxes then set the text of the Button to match the result. You can style the button to look like a ComboBox if that is your preference.

Differentiating arrow clicks between multiple UI-Select controls on one page

Hi I would like to customize behavior of the ui-select little bit. I use two bootstap themed ui-select controls on my page with the help of templatecaches. In the template, I wired up arrow button click event using ng-click tag. That way I can easily catch the click event on the arrow button, and in my controller I can open a popup using function, for instance:
<button ng-click = "someFunctionInTheScope()">
For instance if I have two of those ui-select elements in my view, I need to differentiate which arrow button is clicked to display the correct popup. Since I am using the same template for two ui-select controls and since theoretically I can have any number of these controls on my page, I can not easily add a parameter to the method in the template to differentiate which arrow image of which ui-select control is clicked:
<button ng-click= "someFunctionInTheScope(1)">
Because both ui-select control would be using the same template code and 1 would be passed to the controller function for both of them.
Therefore I need to find a more clever way of changing the template dynamically once and for each control.
So I thought about having something like
<button ng-click= "someFunctionInTheScope($select.id)">
but when I debug it I see that functions parameter is undefined, every time it is clicked.
Can somebody please show me how to hack this?
There is no id property on the $select object. You're best bet is to pass something through the scope of the element containing the ui-select boxes. In other words, your code needs to generate a unique identifier for each ui-select box you have. This could be the $index property of an ng-repeat block, a timestamp, or something dependent on other context.
A little more context and I can provide a more specific answer.

Use multiselect false property with checkboxCellTemplate

I have an ng-grid that utilizes the showSelectionCheckbox: true property with a custom checkboxCellTemplate.
If I remove checkboxCellTemplate I get the functionality I want where only one checkbox can be clicked at a time and clicking another checkbox will remove the selection from the previous one.
I need the template to call a specific function so my question comes down to what property to I have to pass in the template so it can be aware of the multiselect property?
The plunker can be found at http://plnkr.co/edit/nULoI4?p=preview.
So to clarify you're wondering if you can get all the values that are selected when you call a function? Don't you already have this setup in the $scope.selections. You could pass this in the function of the template by doing something like this ng-click="getDeliveryLocation({{selections}})".
Another thought is that you use afterSelectionChange:function(){} and add in whatever you need instead of the ng-click on the checkmarks. This will remove some of the odd issues you have between the different selects.

Disable vaadin combobox dropdown

Hi in vaadin combobox i have only one item added which is in select by default.
So now there is no need in drop down option.
Is there any way to disable dropdown option in combobox?
Regards,
Vignesh
You can try setting the combobox to read-only or disabled if it only has one option. combobox.setReadOnly(true) will make it look like a label while combobox.setEnabled(false) will grey it out and disable the dropdown.
Well, what do you want to show instead? Just a Label? Then check if the container-size you add to the combobox is 1 and show a Label with the only "option" instead.

Resources