Help using custom TriggerField as Editor in Grid
Hi.
I have created a custom TriggerField that will display a window for editing "multiple" values for a field.
If I use this TriggerField in a FormPanel, everything works ok, when I click the trigger, the new window is opened, and the field value is updated after I close this window (more or less what happens with the DatePicker, except I am using really a window).
But when using my custom TriggerField as Editor in one grid, as soon as I click anywhere in the openned window, then the Editor cell in the grid stops editing (as it loses its focus).
Then when closing the window, the value is not set in the editor...
Does any one knows any work around for this?
Thanks for helping!
Michel.
i think for this we need a testcase
Hi, tks for your reply.
However, I figured out how to fix it.
There is the property allowBlur in the Editor class.
One have to set it to true to be able to use a Field that can lose its focus as a field in the grid.
Code:
/** * Sets whether editing should be cancelled when the field is blurred * (defaults to false). * * @param allowBlur true to allow blur */ public void setAllowBlur(boolean allowBlur) { this.allowBlur = allowBlur; }
Michel.
Help ! may be bug ?
TriggerField in EditorGrid.
ver. GXT 2.1.1
TriggerField<String> text = new TriggerField<String>();
text.setReadOnly(true);
// text.setEditable(true);
final CellEditor textEditor = new CellEditor(text);
textEditor.setAllowBlur(true);
column.setEditor(textEditor);
how to set readonly TriggerField and Listener Events.TriggerClick ?
Code:
text.addListener(Events.TriggerClick , new Listener<BaseEvent>() { public void handleEvent(BaseEvent be) { final MessageBox box = MessageBox.prompt("Name", "Please enter your name:"); box.addCallback(new Listener<MessageBoxEvent>() { public void handleEvent(MessageBoxEvent be) { text.setValue(be.getValue()); textEditor.completeEdit(); } }); } });
Why don't you show you window as a Modal?
window.setModal(true);
By the way.
I think that you need to setEditable(false). This will disable user input but will allow to click in the trigger button.
I cannot select the text in TriggerField.
UPD:
Code:
public class TriggerField<D> extends TextField<D> .... @Override protected void onClick(ComponentEvent ce) { if (!readOnly && !editable && getInputEl().dom.isOrHasChild(ce.getTarget())) { onTriggerClick(ce); return; } super.onClick(ce); } public void setEditable(boolean editable) { this.editable = editable; if (rendered) { El fromEl = getInputEl(); if (!readOnly) { fromEl.dom.setPropertyBoolean("readOnly", !editable); } fromEl.setStyleName("x-triggerfield-noedit", !editable); } }
logical error