I am using ComboBox for Dropdown. and when I am select the item,it doesnot pick the value of it.
Code for comboBox :
final SimpleComboBox<String> combo = new SimpleComboBox<String>();
combo.setForceSelection(true);
combo.setTriggerAction(TriggerAction.ALL);
combo.setFieldLabel("Calculation MethodNames");
combo.add(cList);
formPanel.add(combo);
I am retrieving the value as below:
fundSalesCreditCalcMethodDTO.setCalculationMethodName(calculationMethodName.getValue(calculationMethodName.getSelectedIndex()));
Can somebody please help
Related
I'm trying to set default value to this package "mui-tree-select" But I cant do it please some help me out this.
with this sandbox code https://codesandbox.io/s/github/mikepricedev/mui-tree-select
you need to pass selected array of id selected item as a props to TreeView component
<TreeView selected={selected} >.....
this link could help you :
https://www.geeksforgeeks.org/react-mui-treeview-api/
You can set defaultSelected to default selected nodeId property.
const defaultSelectedNodeId = 0;
<TreeView defaultSelected={defaultSelectedNodeId}>
<TreeItem nodeId="0" label={lable}></TreeItem>
</TreeView>
I would like to select widget combo first option by default which is in read only mode.Any suggestion
The select method of Combo sets the selected item.
Combo combo = new Combo(parent, SWT.READ_ONLY | SWT.DROP_DOWN);
combo.setItems(... items array ....);
// Select first item
combo.select(0);
Note that this does not generate a selection changed event. To do that you need to use the notifyListeners call:
Event event = new Event();
event.widget = combo;
event.display = combo.getDisplay();
event.type = SWT.Selection;
combo.notifyListeners(SWT.Selection, event);
Working in Google Web Toolkit (GWT) I am using a CellList to render the details of a list of Tariffs (using a CompositeCell to show a CheckBoxCell next to a custom cell of my own).
I want to filter the list by tariff length (12, 18, 24, 36 months etc). I would like to render a checkbox for each tariff length at the top of the list, and update the dataProvider as necessary when users uncheck and recheck a box.
I do not know in advance the set of tariff lengths, they will be extracted from the result set when the page is rendered. There could just be two (requiring two checkboxes), but possibly there could be 10 (requiring 10 checkboxes) - I only want to render a checkbox for each as needed.
So somehow I need to associate an int value with each checkbox, and then pass that int to a function that updates the list by removing all tariffs that match. I'm just not sure how to add the handler for the checkboxes and how to get the value for that particular box.
This is what I'm thinking:
// panel to hold boxes
private Panel contractLengthPanel = new HorizontalPanel();
textPanel2.add(contractLengthPanel);
// create a set of the terms, by looping the result set
Set<String> contractTerms = new HashSet<String>();
for(ElecTariff tariff : tariffs)
{
contractTerms.add(Integer.toString(tariff.getContractLength()));
}
// loop that set, creating a CheckBox for each value
for(String term : contractTerms)
{
CheckBox box = new CheckBox(term + " Months");
// set all boxes with the same name, and a unique id
box.getElement().setAttribute("name", "termBoxes");
box.getElement().setAttribute("id", "termBox" + term);
contractLengthPanel.add(box);
}
Now I'm not sure if I'm along the right lines here, but now I have each box as part of the same group (they have the same name) I would like to use that to add a handler that is called when a box is checked or unchecked, passing the box id (which contains the tariff length) to that function.
I hope this wasn't too confusingly written. Help appreciated.
There really is nothing like a "group of checkboxes" in HTML, and neither there is in GWT. There are kind of "groups of radiobuttons" though, but it's only about having their checked state mutually exclusive, it doesn't change anything to the way you work with them from code.
You have to listen to changes on each and every checkbox.
What you can do though is to use the same event handler for all your checkboxes; something like:
ValueChangeHandler<Boolean> handler = new ValueChangeHandler<Boolean>() {
#Override
public void onValueChange(ValueChangeEvent<Boolean> event) {
CheckBox box = (CheckBox) event.getSource();
String id = box.getFormValue();
boolean checked = box.getValue();
…
}
};
(note: I used getFormValue() rather than getElement().getId(); I believe it's a better choice: it's specifically made to associate a value with the checkbox)
I am trying to add a list of strings to the autocomplete values returned to the autcomplete Text bar
when these values are selected i must process them locally before retrieving information from the google servers.
this is the code which binds the AutoComplete entity to the auto text field.
final AutoCompleteOptions options = new AutoCompleteOptions();
options.setTypes(Arrays.asList(new String[] { "geocode" }));
final AutoComplete autoComplete = new AutoComplete(this.auto.getElement(), options);
autoComplete.bindTo("bounds", (com.google.gwt.maps.client.Map) this.mapWidget.getMap());
Any ideas?
I have a SelectItem object which has a few items. I set a value MAP with:
organizations[0] = "A";
organizations[0] = "B";
selectItem.setValueMap(organizations);
When displayed, the combo box is showing "A" as selected item. Then, I need to programatically select value "B" and select this on the current SelectItem object. I've been looking all over the place with no avail.
Anyone?
If you want any option of selectItem to be manually selected, then you should try following:
selectItem.setValue("B");
After doing this when you open the picklist of the selectItem, value "B" will be highlighted.