PDA

View Full Version : [GXT 2.2.5] ComboBox has no access to cancel query (dqTask) and can't stop tab select



The_Jackal
30 Jan 2012, 2:21 PM
ComboBox has no way for another class or a subclass to cancel the query (dqTask). Please provide a public or protected cancel method that will call dqTask.cancel() as this is a common requirement if the combo subclass needs to cancel query and collapse the combo (e.g. when a certain character / operator is encountered).

The closest method is triggerBlur() as it cancels and collpases, but it also blurs the component which is not always desired.

In my case the suggestions that the combo is returning are part of a formula and I want to cancel the query when an operator is detected, so the next operand will start a new query.

My current workaround is to use JSNI to access the private field.

*Update: An alternative would be stop tab being used to pick a suggestion as this
both picks an item and tabs to the next field (rarely what you want to do!).

Please allow the KeyNav to be set (rather than creating it anonymously in initComponent() ). Or allow the onTab() method of the KeyNav to have a flag to choose if tab is allow to pick options (allowTab).

Anonymous creation of the KeyNav prevents any subclass from "unbinding" this KeyNav to provide their own and it not very extension friendly. To workaround it I have to override onViewClick to ignore tab keyCodes.

Regards,
The_Jackal

wwab
19 Nov 2012, 6:51 AM
+1 for public cancel query method

Colin Alworth
20 Nov 2012, 10:58 AM
Two other alternatives (I'm working on a bug in 3.x that hits the queryTask, so as long as I've made the giant cache miss of re-reading all of this code, thought I'd offer some ideas):

* Override doQuery(String, boolean) to check your own current state and logic to decide if you continue - other wise return early without calling super.doQuery.
* Or, if you don't want to subclass ComboBox, listen for the Events.BeforeQuery event (of type FieldEvent), and, again, based on your current state and logic, cancel the query action.

These end up having the same effect as canceling the task, and don't require any JSNI workaround.

wwab
20 Nov 2012, 10:24 PM
The second options seems to be a good solution(better design than first)

Until now i solved the problem by subclassing ComboBox and implementing a method:

public void triggerBlur() {
triggerBlur(new ComponentEvent(this));
}

this also cancels the query. but your approach is better