PDA

View Full Version : Typeahead suggestion height is not correct.



vastiridev
21 Jul 2010, 4:06 AM
Hi there,
We are trying to use a ComboBox as a typeahead widget, but the height of the suggestions is calculated when the loading text is visible - therefore it is only possible to see 1 suggestion at a time!

It is only after closing and reopening the suggestions drop-down that the list is displayed correctly.

Workarounds welcome.

Thanks,
Matt



public class UserLookupDevice {

private ComboBox<ModelData> lookupWidget = new ComboBox<ModelData>();
private ListStore<ModelData> store;
private UserServiceAsync service = GWT.create(UserService.class);
private BeanModelFactory factory = BeanModelLookup.get().getFactory(User.class);

public UserLookupDevice() {
DataProxy<ModelData> proxy = new DataProxy<ModelData>() {
public void load(DataReader<ModelData> reader, Object loadConfig, AsyncCallback<ModelData> callback) {
service.getUsers(0, 20, lookupWidget.getRawValue(), new AsyncCallbackAdapter<PagingLoadResult<User>>() {
@Override
public void onSuccess(PagingLoadResult<User> result) {
store.removeAll();
for (User user : result.getData()) {
store.add(factory.createModel(user));
}
}
});
}
};
BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy);
store = new ListStore<ModelData>(loader);

lookupWidget.setStore(store);
lookupWidget.setDisplayField("username");
lookupWidget.setTypeAhead(true);
lookupWidget.setTypeAheadDelay(1);
lookupWidget.setTriggerAction(TriggerAction.ALL);
}
}

sven
21 Jul 2010, 4:16 AM
Please post a testcase that works for everyone and has no further depencies.

vastiridev
21 Jul 2010, 4:27 AM
Here you go.


public class UserLookupDevice {

private ComboBox<ModelData> lookupWidget = new ComboBox<ModelData>();
private ListStore<ModelData> store;

public UserLookupDevice() {
DataProxy<ModelData> proxy = new DataProxy<ModelData>() {
public void load(DataReader<ModelData> reader, Object loadConfig, AsyncCallback<ModelData> callback) {
BaseModelData item1 = new BaseModelData();
BaseModelData item2 = new BaseModelData();
item1.set("username", "foo");
item2.set("username", "bar");
store.add(item1);
store.add(item2);
}
};
BaseListLoader<ListLoadResult<ModelData>> loader = new BaseListLoader<ListLoadResult<ModelData>>(proxy);
store = new ListStore<ModelData>(loader);

lookupWidget.setStore(store);
lookupWidget.setDisplayField("username");
lookupWidget.setTypeAhead(true);
lookupWidget.setTypeAheadDelay(1);
lookupWidget.setTriggerAction(TriggerAction.ALL);
}

public Widget getLookupWidget() {
return lookupWidget;
}
}

sven
21 Jul 2010, 4:29 AM
You should run the code you post. That is demonstratnig nothing, as it is doing nothing with typeAhead.

vastiridev
21 Jul 2010, 4:33 AM
Works fine for me.

sven
21 Jul 2010, 4:35 AM
Well, it shoud not, because minChars defaults to 4

Nevertheless. When you are using a loader, you should use it and let the loader modify the store and not modify it directly

vastiridev
21 Jul 2010, 4:54 AM
We shouldn't be modifying the store directly as this doesn't fire the loadData event. There is a callback parameter on the proxy that we should call instead.

If minChars is set to 4 then type 4 characters in! The example was fine, but thanks all the same for the prompt response.

sven
21 Jul 2010, 4:58 AM
We shouldn't be modifying the store directly as this doesn't fire the loadData event. There is a callback parameter on the proxy that we should call instead.


You are modifing the store on your own. You directly call store.add. When using a loader, you never do this.


If minChars is set to 4 then type 4 characters in! The example was fine, but thanks all the same for the prompt response.
Non of your items has 4 chars. So it wont even work correctly, if your code would be correct.

vastiridev
21 Jul 2010, 5:08 AM
It was sufficient to show my problem whether any items had 4 chars or not.

Why are you complaining at a customer?

sven
21 Jul 2010, 5:27 AM
I am not complaining. I helped you and gave you the solution.

I am just saying that your testcode did not make any sense to show a typeahead problem, as it never is doing any typehead. If all of your posts are not showing any typehead problem, maybe your description was not enough so that people that dont know your problem can understand it.

If you dont want that i spend my freetime on helping you, i will stop now. I told you what is wrnog with your code, so you can fix the other problem you probably meant, but is not linked to typehead.