1

I am quite new to extjs and I would like to have an inline editor for my tree, I know there is a TreeEditor in extjs and I am not quite sure how to use it, does anyone have a small example to get me started with the Ext.tree.TreeEditor ?

Thanks

Pax
  • 13
  • 1
  • 6

1 Answers1

5

Yea, this one does suck a bit because there's no good docs online. Here's a short sample, cribbed from the docs and from ExtJS in Action:

var tree = new Ext.tree.TreePanel({
    root: this.getChildren(),
    height: 300,
    loader: new Ext.tree.TreeLoader(),
    useArrows: true,
    autoScroll: true,
    listeners: {
        dblclick: onTreeNodeDblClick
    }
});

var treeEditor = new Ext.tree.TreeEditor(tree, {}, {
    cancelOnEsc: true,
    completeOnEnter: true,
    selectOnFocus: true,
    allowBlank: false,
    listeners: {
        complete: onTreeEditComplete
    }
});

onTreeNodeDblClick: function(n) {
    treeEditor.editNode = n;
    treeEditor.startEdit(n.ui.textNode);
}

onTreeEditComplete: function(treeEditor, o, n) {
    //o - oldValue
    //n - newValue
}
Jonas
  • 4,454
  • 3
  • 37
  • 45
  • I didn't think the documentation was that bad http://dev.sencha.com/deploy/dev/docs/?class=Ext.tree.TreeEditor. One trick to make it easier to read, is to click the "Hide inherited members" button, then you can concentrate on the editor features itself. – Ruan Mendes Apr 13 '11 at 17:51
  • there is still almost no examples, in my opinion, so yeah docs suck a bit – llamerr Apr 26 '12 at 13:35