Hi,
i am using the ComboBox as a cross reference field that visualizes 0:1 references between database tables.
If you try to use the ComboBox for tables > 5.000 records, it will become pretty slow if you are using SQLContainer since the combo box tries to navigate to the page of the selected item. And the SQLContainer has to lookup for the index of the given item id.
So i did a hack that works really fine.
comboBox.setScrollToSelectedItem(false) will tell the combo box to stop scrolling to the record with the given id.
But then the combo box won’t show any result since the selection has to be part of its options.
OK, lets add the current value to the list of options (see code below) an everything works fine again!
For sure, the combo box does not scroll to the page with the selected record, but now it is pretty fast!
private static class ExtendedComboBox extends ComboBox {
public ExtendedComboBox() {
super();
}
protected List<?> getOptionsWithFilter(boolean needNullSelectOption) {
@SuppressWarnings("unchecked")
List<Object> options = (List<Object>) super
.getOptionsWithFilter(needNullSelectOption);
if (getValue() != null) {
options.add(0, getValue());
}
return options;
}
}
Best,
Florian