-
8 Mar 2012 2:25 PM #1
ComboBox doQuery method seems not working with Remote Loader
ComboBox doQuery method seems not working with Remote Loader
Hi,
I found that the method doQuery(String query, boolean force) for the ComboBox in gxt 3.0 is not taking in count the query string when the ComboBox has a Loader and so the ComboBoxCell query mode is QueryMode.REMOTE.
Reading the code I found this at the doQuery method of the ComboBoxCell :
And below that the method getParams(String query) of the same class:Code:if (force || query.length() >= minChars) { if (!useQueryCache || !query.equals(lastQuery)) { lastQuery = query; if (mode == QueryMode.LOCAL) { ..... ..... }else{ expand(context, parent, updater, value); @SuppressWarnings("unchecked") PagingLoader<PagingLoadConfig, PagingLoadResult<?>> l = (PagingLoader<PagingLoadConfig, PagingLoadResult<?>>) loader; l.load(getParams(query)); }
It seems the query string was not taking in count.Code:protected PagingLoadConfig getParams(String query) { PagingLoadConfig config = null; if (loader.isReuseLoadConfig()) { config = (PagingLoadConfig) loader.getLastLoadConfig(); } else { config = new PagingLoadConfigBean(); } config.setLimit(pageSize); config.setOffset(0); // config.set("query", query); return config; }
waiting for your comments.
Regards
Daniel
-
2 Oct 2012 2:51 PM #2
Hi,
I recently came across the same problem. Could you please explain how should we now handle remote loading of data in a combobox when the parameter "query" is not filled anymore? In my previous implementation with GXT2 I used the value under key "query" as a search string in my business method (it was a combobox with remote autocomplete).
Best regards,
Adam Sas
-
2 Oct 2012 9:48 PM #3
Thanks for this - not sure how it got missed the first time around, though not being in the Bugs forum probably didn't help.
In the http://www.sencha.com/examples/#Exam...vancedcombobox sample, this code is used as a workaround:
I've moved this to the bug forum, and will update it with progress on the issue.Code:PagingLoader<ForumLoadConfig, ForumListLoadResult> loader = new PagingLoader<ForumLoadConfig, ForumListLoadResult>( proxy, reader); loader.useLoadConfig(TestAutoBeanFactory.instance.loadConfig().as()); loader.addBeforeLoadHandler(new BeforeLoadHandler<ForumLoadConfig>() { @Override public void onBeforeLoad(BeforeLoadEvent<ForumLoadConfig> event) { String query = combo.getText(); if (query != null && !query.equals("")) { event.getLoadConfig().setQuery(query); } } });
EDIT: The reason it doesn't work as is is that the PagingLoadConfig data doesn't have a field for query, while the ForumLoadConfig as used in the sample above has a specific piece for it. While it may be possible to support a FilterPagingLoadConfig by default, I'm not certain that we aim to expect that use case.
For now, I would advise a workaround like the one shown - this may end up being the correct resolution for this.
-
27 Nov 2012 7:58 AM #4
My solve with FilterPagingLoadConfigBean
My solve with FilterPagingLoadConfigBean
Here's a way to do it without using any objects from the sample package. I'm making a callback using a "User" object. The combobox is submitting the "lastName" filter.
Here's the UserProperties interface..Code:UserProperties props = GWT.create(UserProperties.class); ListStore<User> userListStore = new ListStore<User>(props.id()); RpcProxy<FilterPagingLoadConfig, PagingLoadResult<User>> proxy = new RpcProxy<FilterPagingLoadConfig, PagingLoadResult<User>>() { @Override public void load(FilterPagingLoadConfig loadConfig, final AsyncCallback<PagingLoadResult<User>> callback) { // call the actual service you have ApplicationService.Util.getInstance().getAllUsers(loadConfig, callback); } }; final PagingLoader<FilterPagingLoadConfig, PagingLoadResult<User>> loader = new PagingLoader<FilterPagingLoadConfig, PagingLoadResult<User>>( proxy); loader.setRemoteSort(true); loader.addLoadHandler(new LoadResultListStoreBinding<FilterPagingLoadConfig, User, PagingLoadResult<User>>(userListStore)); final ComboBox<User> userComboBox = new ComboBox<User>(userListStore, props.fullName()); userComboBox.setName("lastName"); userComboBox.setLoader(loader); userComboBox.setTypeAhead(true); userComboBox.setEmptyText("Change User..."); userComboBox.setPageSize(20); userComboBox.setMinChars(3); loader.addBeforeLoadHandler(new BeforeLoadEvent.BeforeLoadHandler<FilterPagingLoadConfig>() { @Override public void onBeforeLoad(BeforeLoadEvent<FilterPagingLoadConfig> event) { String query = userComboBox.getText(); event.getLoadConfig().getFilters().clear(); if (query != null && !query.equals("")) { FilterConfig filterConfig = new FilterConfigBean(); filterConfig.setField(userComboBox.getName()); filterConfig.setValue(query); event.getLoadConfig().getFilters().add(filterConfig); } } }); loader.useLoadConfig(new FilterPagingLoadConfigBean());
Code:interface UserProperties extends PropertyAccess<User> { ModelKeyProvider<User> id(); LabelProvider<User> fullName(); }
-
3 Dec 2012 9:20 PM #5
Thanks for the more complete workaround - of course, it'll always need to have its generics modified to match the current example being used, and if your server isn't expecting a full list of filter configs just to populate a ComboBox, you'll need something more specific like in the Advanced ComboBox example.
You found a bug! We've classified it as
EXTGWT-2468
.
We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.


Reply With Quote