-
10 Mar 2010 10:00 AM #1
TreePanel text change on model not forwarded
TreePanel text change on model not forwarded
When using a TreePanel and changing the text field of the BaseModelData, the displayed text on the tree item is not updated.
Using:
Web mode
GXT 2.1.1
GWT 2.0.2
Firefox 3.5.8
Sample code:
Both changing the field on the Model directly and retrieving the Model from the Store and then changing the field do not have any effect on the text displayed on the TreePanel.Code:public class MainEntryPoint implements EntryPoint { public void onModuleLoad() { final TreePanel tree = new TreePanel(new TreeStore()); tree.setDisplayProperty("text"); final ModelData m = new BaseModelData(); m.set("text", "SomeText"); tree.getStore().add(m, false); RootPanel.get().add(tree); Button b1 = new Button("A"); b1.addSelectionListener(new SelectionListener<ButtonEvent>(){ @Override public void componentSelected(ButtonEvent ce) { m.set("text", "A"); } }); RootPanel.get().add(b1); Button b2 = new Button("B"); b2.addSelectionListener(new SelectionListener<ButtonEvent>(){ @Override public void componentSelected(ButtonEvent ce) { List<ModelData> l = tree.getStore().getAllItems(); for(ModelData m: l) { m.set("text", "B"); } } }); RootPanel.get().add(b2); } }
Any help appreciated!
-
10 Mar 2010 10:06 AM #2
If you are looking for help, you need to post in the correct forum. I moved the post now. ALso this was dicussed several times and you can try to use the forum search.
-
10 Mar 2010 10:07 AM #3
BaseModelData does not fire any events. So you need to call update on the store manually.
-
10 Mar 2010 10:14 AM #4
Thanks for your quick reply! - next time I will be more cautious before posting in Bugs :-)
I was not aware of the fact the BaseModelData does not fire events, nor could I find any useful hints while search for "TreePanel text change".
-
10 Mar 2010 10:15 AM #5
You can also change it to BaseModel and before adding the model set monitor changes to true on the store. These are the two solutions for your problems
-
10 Mar 2010 10:24 AM #6
Yes, changing my superclass to BaseModel was all I had to do. I had monitorChanges set to true already.
Thanks again, you really helped me a lot!


Reply With Quote