PDA

View Full Version : set null value to combobox



diegolovison
26 Aug 2010, 11:24 AM
How I can set the combobox value equals null when the user clear the input text and press tab or click out of the component (blur)?

thanks

sven
26 Aug 2010, 11:25 AM
The combobox should already do that. Can you please post a testcase that is failing and is implementing entrypoint?

sven
26 Aug 2010, 11:26 AM
This thread, also opened by you, explains exactly what you are asking for: http://www.sencha.com/forum/showthread.php?100150-combobox-getValue

diegolovison
26 Aug 2010, 12:17 PM
yes this work...

but if I clear the value like I told, when I "blur the field" the event SelectionChange dont fire...

sven
26 Aug 2010, 12:19 PM
You are not changing the selection directly. The value just changes.

You need to listen to the Events.Change event for this. Actually it is even more safe to always listen to this event.

diegolovison
26 Aug 2010, 12:31 PM
have plans to change this behaviour?

sven
26 Aug 2010, 12:33 PM
No, as there is an event for this which is the Events.Change event. Why should we add a second one for exact same?

diegolovison
26 Aug 2010, 12:36 PM
if I have a linked combobox, when the combo1 change the value, the combo2 should change the value too.
and using the example below isnt possible...



combo1.addSelectionChangedListener(new SelectionChangedListener<BeanModel>() {
public void selectionChanged(SelectionChangedEvent<BeanModel> se) {
combo2.setValue(null);
....
}
}

sven
26 Aug 2010, 12:39 PM
You are not using the Events.Change event as suggested.


combo1.addListener(Events.Change, new Listener<BaseEvent>(){
public void handleEvent(BaseEvent be){
combo2.setValue(null);
}
});

diegolovison
26 Aug 2010, 12:42 PM
using Change work, I know.

but I would like use SelectionChangedListener :)

sven
26 Aug 2010, 12:45 PM
Why do you would like to use that? What differents would it make?

diegolovison
27 Aug 2010, 5:23 AM
only because make more sence :)

if you addSelectionChangeListener you would like that when the value was changed for null, this method should be invocated.