Pax
Pax

Reputation: 13

How to use ExtJS TreeEditor

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

Upvotes: 1

Views: 5612

Answers (1)

Jonas
Jonas

Reputation: 4584

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
}

Upvotes: 5

Related Questions