PDA

View Full Version : TreeGrid does not epxand?



vultoor
13 Nov 2009, 9:49 AM
Hi folks,

newbie to Ext GWT, I am using 2.0.1

I have a TreeGrid for which I would like to expand the first node when it first loads. I have tried using each of the following approaches but with no success.

tree.setExpanded(myBaseTreeModel, true, true);

tree.getSelectionModel().fireEvent(Events.Expand);

Even thinking that it's async, I tried the following which is to add a listener on the grid store and expand nodes on dataChanged event:

tree.getTreeStore().addStoreListener(new StoreListener<ModelData>() {
@Override
public void storeDataChanged(StoreEvent<ModelData> se) {
System.out.println("MyTreeGrid::storeDataChanged()");
for (ModelData model : tree.getTreeStore().getRootItems()) {
tree.setExpanded(model, true, true);
}
}
});

I noticed this method is not even called (out of System.out.println statement does not appear).

Please suggest what to do.

regards,

Sharath

sven
13 Nov 2009, 10:02 AM
You probably want to update to 2.0.4 or wait for 2.1. There was a small issue that got correctly, but could lead to expand not working everytime.

livinglegends
25 Nov 2009, 8:54 PM
Hi sven,

I am facing same problem of node expanding runtime.
As per ur comment, I have migrated my project to 2.1 but still facing same issue.

Can you give me code to expand selected node run time?

Please reply ASAP.

Thanx
LivingLegends

Nico33
25 Mar 2010, 11:19 AM
Hi all,

I encounter the same problem with GXT 2.1.1.

this is my testcase


public class TestApp implements EntryPoint
{
public void onModuleLoad()
{
Viewport viewport = new Viewport();

LayoutContainer container = new LayoutContainer();
container.setLayout(new FlowLayout(10));

Folder model = TestData.getTreeModel();
TreeStore<ModelData> store = new TreeStore<ModelData>();
store.add(model.getChildren(), true);

ColumnConfig name = new ColumnConfig("name", "Name", 100);
name.setRenderer(new TreeGridCellRenderer<ModelData>());
ColumnConfig date = new ColumnConfig("author", "Author", 100);
ColumnConfig size = new ColumnConfig("genre", "Genre", 100);
ColumnModel cm = new ColumnModel(Arrays.asList(name, date, size));

ContentPanel cp = new ContentPanel();
cp.setBodyBorder(false);
cp.setHeading("TreeGrid");
cp.setButtonAlign(HorizontalAlignment.CENTER);
cp.setLayout(new FitLayout());
cp.setFrame(true);
cp.setSize(600, 300);

final TreeGrid<ModelData> tree = new TreeGrid<ModelData>(store, cm);
tree.setBorders(true);
tree.setAutoExpandColumn("name");
tree.setTrackMouseOver(false);

for (ModelData item : store.getRootItems())
{
tree.setExpanded(item, true);
}

cp.add(tree);
container.add(cp);
viewport.add(container , new AnchorData("100% 100%", new Margins(10)));
RootPanel.get().add(viewport);
}
}
and nothing is expanded.

Thanks for your answer

sven
25 Mar 2010, 11:24 AM
tree.addListener(Events.ViewReady, new Listener<GridEvent<ModelData>>(){

public void handleEvent(GridEvent<ModelData> be) {
for (ModelData item : tree.getTreeStore().getRootItems()) {
tree.setExpanded(item, true);
}

}

});

Nico33
25 Mar 2010, 12:05 PM
Thanks,

it's working =D>