PDA

View Full Version : Enable CellEditing in treePanel by code



pixman
12 Jul 2012, 1:15 AM
Hello,
I'm using a treepanel for manage folders.

I have add CellEditing for manage rename action.

I have a simple question.

When i create new folder, i want select it in the tree panel, and activate the cellEditing by code. user can edit the new folder name and save new name.

But i don't know how to get ( no select, just get ) the new row for start editing.

Thanks a lot for your help

redraid
12 Jul 2012, 3:44 AM
Example:

var store = Ext.create('Ext.data.TreeStore', {
root: {
expanded: true,
children: [
{ text: "detention", leaf: true },
{ text: "homework", expanded: true, children: [
{ text: "book report", leaf: true },
{ text: "alegrbra", leaf: true}
] },
{ text: "buy lottery tickets", leaf: true }
]
}
});

var editPlugin = Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
});

Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 250,
store: store,
rootVisible: false,
renderTo: Ext.getBody(),
plugins: [
editPlugin
],
columns: [{
xtype: 'treecolumn',
dataIndex: 'text',
flex: 1,
editor: {xtype: 'textfield'}
}],
tbar: [{
text: 'add',
handler: function (btn) {
var tree = btn.up('treepanel'),
root = tree.getRootNode(),
node;

// Add new node
node = root.appendChild({
text: 'new node',
leaf: true
});

// Edit new node
editPlugin.startEdit(node, 0);
}
}]
});

pixman
12 Jul 2012, 5:43 AM
Thank for your help.

I have modified you source for adapting to my controller

i have insert my plugin with an pluginID

plugins : [Ext.create('Ext.grid.plugin.CellEditing', { pluginId:'folderNameEditing', clicksToEdit: 2 })]

and in my controller, i select it with this code



// this.getFolderTree() => The selector for my grid panel

this.getFolderTree().getPlugin('folderNameEditing').startEdit(newRecord,0);

I'ts work fine !