Java vaadin 7.75如何将组合框添加到网格?
我在瓦丁7.7上,我把桌子换成了格子。只是我不能像我想的那样个性化我的手机。在这里,我想在arraylist中的列上添加组合框并检索所选的值 以下是我的一些代码: 在这里,我创建了我的IndexedContainerJava vaadin 7.75如何将组合框添加到网格?,java,vaadin,Java,Vaadin,我在瓦丁7.7上,我把桌子换成了格子。只是我不能像我想的那样个性化我的手机。在这里,我想在arraylist中的列上添加组合框并检索所选的值 以下是我的一些代码: 在这里,我创建了我的IndexedContainer IndexedContainer indexedContainer = new IndexedContainer(); indexedContainer.addContainerProperty("Type de véhicule",String.class,""); 在
IndexedContainer indexedContainer = new IndexedContainer();
indexedContainer.addContainerProperty("Type de véhicule",String.class,"");
在此我添加我的项目:
indexedContainer.addItem(listValue);
indexedContainer.getContainerProperty(listValue,
key.get(0)).setValue(
String.valueOf(listValue.get(0)));
最后,我将对象置于可编辑状态,并使用此功能在备份过程中执行操作:
grid.getEditorFieldGroup().addCommitHandler(new FieldGroup.CommitHandler() {
@Override
public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
}
@Override
public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException {
如果您有任何想法或建议,请不要犹豫:)
晚安试试这个:
grid.getColumn("state").setEditorField(getComboState());
其中getComboState为:
private Field<?> getComboState() {
ComboBox comboBox = new ComboBox();
comboBox.addItem("approve");
comboBox.addItem("no-approve");
comboBox.setImmediate(true);
comboBox.setNullSelectionAllowed(false);
return comboBox;
}
private字段getComboState(){
ComboBox ComboBox=新建ComboBox();
组合框。添加项(“批准”);
组合框。添加项(“无批准”);
comboBox.setImmediate(true);
comboBox.SetNullSelectionLowed(false);
返回组合框;
}
您可以使用以下内容:
List<String> values = obtainValues();
IndexedContainer container = new IndexedContainer();
//Add other properties...
container.addContainerProperty("comboBox", ComboBox.class, null);
//Do more stuff
ComboBox cb = new ComboBox();
cb.addItems(values);
item.getItemProperty("comboBox").setValue(cb);
要获取组合框的值,请执行以下操作:
Item item = container.getItem(itemId);
ComboBox cb = item.getItemProperty("comboBox").getValue();
String value = (String) cb.getValue();
Item item = container.getItem(itemId);
ComboBox cb = item.getItemProperty("comboBox").getValue();
String value = (String) cb.getValue();