Post new topic Reply to topic  [ 3 posts ] 

Board index : GWT-Ext Forums : GWT-Ext 2.x Discussion

Author Message
 Post subject: [SOLVED] Force a PropertyGridPanel to update its view
PostPosted: Tue Mar 11, 2008 3:36 am 
Offline

Joined: Mon Mar 10, 2008 2:59 am
Posts: 5
I am trying to change the value being entered in the editor for a property grid panel. The issue I am running up against is demonstrated by the sample code below. If you edit the value and CLICK to exit the field, the value will be updated on the display. If however, you press ENTER, the display does not get updated. I have tried using the two ways below (one commented out). Does anybody have a suggestion for a more reliable way to accomplish this?

Thanks!

PropertyGridPanel grid = new PropertyGridPanel();
grid.setStore(new Store(){});
HashMap source = new HashMap();
source.put("Text", "value");
grid.setSource(source);
HashMap customEditors = new HashMap();
final TextField lcaseTextField = new TextField();
lcaseTextField.addListener(new TextFieldListenerAdapter(){
public void onChange(Field field, Object newVal, Object oldVal){
lcaseTextField.setRawValue(((String)newVal).toLowerCase());
}
});
/*lcaseTextField.setValidator(new Validator(){
public boolean validate(String value) throws ValidationException {
lcaseTextField.setRawValue(value.toLowerCase());
return true;
}
});*/
customEditors.put("Text", new GridEditor(lcaseTextField));
grid.setCustomEditors(customEditors);
this.add(grid);


Back to top
 Profile  
 
 Post subject: Re: Force a PropertyGridPanel to update its view
PostPosted: Tue Mar 11, 2008 10:29 pm 
Offline

Joined: Mon Mar 10, 2008 2:59 am
Posts: 5
I have found a workaround that seems to work for the cases I have tried

final TextField lcaseTextField = new TextField();
lcaseTextField.addListener(new TextFieldListenerAdapter(){
public void onBlur(Field field) {
updateValue();
}
public void onSpecialKey(Field field, EventObject e){
updateValue();
}
private void updateValue(){
lcaseTextField.setRawValue(lcaseTextField.getValueAsString().toLowerCase());
}
});

The "onBlur" catches the user leaving the field by clicking off, the onSpecialKey catches them leaving by enter or tab or anything like that.


Back to top
 Profile  
 
 Post subject: Re: Force a PropertyGridPanel to update its view
PostPosted: Fri Mar 14, 2008 12:26 am 
Offline
Site Admin

Joined: Fri Dec 14, 2007 12:27 pm
Posts: 1017
Thats the right way to handle it.

Sanjiv


Back to top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

Board index : GWT-Ext Forums : GWT-Ext 2.x Discussion


Who is online

Users browsing this forum: Yahoo [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Style by Midnight Phoenix & N.Design Studio
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.