blackbox23
6 Dec 2010, 6:34 AM
Hello,
I really hope someone could help me out on this one. Been trying to figure this out for 3 days now.
I want to insert an empty value to a combo box drop down list. I did this by adding a modeldata with " " as the displayfield. The drop down list displays correctly..(please see code 1/attachment 1). However when I select it, the combobox field also displays " ", so I added a ListModelPropertyEditor and overrode getStringValue, but it doesn't work, and. worse, the drop down list doesnt work too. (please see code2/attachment 2).
Here's my code:
code1:
final ComboBox<ModelData> combo = new ComboBox<ModelData>();
combo.setFieldLabel("test");
ListStore<ModelData> store = new ListStore<ModelData>();
combo.setStore(store);
combo.setDisplayField("display");
combo.setTriggerAction(TriggerAction.ALL);
ModelData m = new BaseModelData();
m.set("display", " ");
m.set("value", 1);
store.add(m);
m = new BaseModelData();
m.set("display", "2");
m.set("value", 2);
store.add(m);
fp.add(combo, new FormData("-20"));
code2:
final ComboBox<ModelData> combo = new ComboBox<ModelData>();
combo.setFieldLabel("test");
ListStore<ModelData> store = new ListStore<ModelData>();
combo.setStore(store);
combo.setDisplayField("display");
combo.setTriggerAction(TriggerAction.ALL);
combo.setPropertyEditor(new ListModelPropertyEditor<ModelData>() {
@Override
public String getStringValue(ModelData value) {
if (value.get("display").equals(" ")) {
return "";
}
return (String) value.get("display");
}
});
ModelData m = new BaseModelData();
m.set("display", " ");
m.set("value", 1);
store.add(m);
m = new BaseModelData();
m.set("display", "2");
m.set("value", 2);
store.add(m);
fp.add(combo, new FormData("-20"));
I'm using GXT 2.1.1/GXT2.0. Please help me.
Thanks.
I really hope someone could help me out on this one. Been trying to figure this out for 3 days now.
I want to insert an empty value to a combo box drop down list. I did this by adding a modeldata with " " as the displayfield. The drop down list displays correctly..(please see code 1/attachment 1). However when I select it, the combobox field also displays " ", so I added a ListModelPropertyEditor and overrode getStringValue, but it doesn't work, and. worse, the drop down list doesnt work too. (please see code2/attachment 2).
Here's my code:
code1:
final ComboBox<ModelData> combo = new ComboBox<ModelData>();
combo.setFieldLabel("test");
ListStore<ModelData> store = new ListStore<ModelData>();
combo.setStore(store);
combo.setDisplayField("display");
combo.setTriggerAction(TriggerAction.ALL);
ModelData m = new BaseModelData();
m.set("display", " ");
m.set("value", 1);
store.add(m);
m = new BaseModelData();
m.set("display", "2");
m.set("value", 2);
store.add(m);
fp.add(combo, new FormData("-20"));
code2:
final ComboBox<ModelData> combo = new ComboBox<ModelData>();
combo.setFieldLabel("test");
ListStore<ModelData> store = new ListStore<ModelData>();
combo.setStore(store);
combo.setDisplayField("display");
combo.setTriggerAction(TriggerAction.ALL);
combo.setPropertyEditor(new ListModelPropertyEditor<ModelData>() {
@Override
public String getStringValue(ModelData value) {
if (value.get("display").equals(" ")) {
return "";
}
return (String) value.get("display");
}
});
ModelData m = new BaseModelData();
m.set("display", " ");
m.set("value", 1);
store.add(m);
m = new BaseModelData();
m.set("display", "2");
m.set("value", 2);
store.add(m);
fp.add(combo, new FormData("-20"));
I'm using GXT 2.1.1/GXT2.0. Please help me.
Thanks.