PDA

View Full Version : EditorTreeGrid - how to programmaticaly start editing newly inserted item



mistigi
16 Jun 2009, 2:21 PM
I have an EditorTreeGrid with a context menu that inserts a new item into the tree. I would like to start editing a newly inserted item right after it happens.

EditorTreeGrid has a method


public void startEditing(int row,int col);however I am having problem finding row index of my newly created item (or its parent)


insert.addSelectionListener(new SelectionListener<MenuEvent>() {
public void componentSelected(MenuEvent ce) {

BeanModel bnSelectedPath = tree.getSelectionModel().getSelectedItem();
Path selectedPath=(Path)bnSelectedPath.getBean();
BeanModelFactory factory = BeanModelLookup.get().getFactory(Path.class);
Path childPath = new Path("New path");
childPath.setParentId(selectedPath.getId());
BeanModel bnChildPath = factory.createModel(childPath);
selectedPath.getChildCategories().add(0,childPath);

store.insert(bnSelectedPath, bnChildPath,0,false);//<--- insert here
tree.setExpanded(bnSelectedPath, true);
tree.startEditing(0,0);// <----------- problem here

}
}); What is a proper way to locate row index where the new item was inserted ? Also where should I be calling tree.startEditing method ? Like in the example above - right after I call store.insert method - or should I listen somewhere for an event that fires when the item is inserted ?

EditTreeGrid is backed by TreeStore<BeanModel>. I am using GXT 2.0 M3