23 Apr 2012 7:31 AM #1
We had been heavily using the methods to get and set the Displayfield for comboboxes in 2.1. What can be used to replace this functionality in 3.0 since we are currently converting our application to 3.0?
25 Apr 2012 5:21 PM #2
The only way I could figure out how to do this was to assign a custom PropertyEditor. It's a pain though, because you need to override the parse method as well as the display method. There really should be something like a:
26 Apr 2012 5:15 AM #3
Thanks for the reply. Sencha, is there some reason this method was removed from 3.0?
26 Apr 2012 8:13 AM #4
GXT 2 relies heavily on a sort of psuedo-reflection offered by the interface BaseModel that all model objects use anywhere had to implement. By requiring this, the relatively new RequestFactory and AutoBean features in GWT cannot be used by GXT data components, as you can't just add new method to the interfaces to be created by GWT.
Instead, GXT 3 allows properties to be retrieved and modified generically using the ValueProvider interface. Two main methods exist here - how to set the value of a given object, and how to get the value of a given object. Simple instances where you are just reading or writing the same value over and over can be generated automatically using the PropertyAccess interface. LabelProvider is another such interface - its getLabel method takes a single object and returns a string based on that.
You can build this functionality for your own use case with a LabelProvider that can be instructed to change how it works. ComboBoxCell doesn't allow the LabelProvider instance to be changed because it may have been used in the creation of the listview, and the user may or may not want that to be changed as well.
So the method can't exist as-is in GXT 3, but you can get the same customizability by implementing your own LabelProvider, and manipulating its logic to decide which property to show and how.