PDA

View Full Version : editor.on('complete') - all edited items are kept in editor



burton449
9 Jun 2014, 7:07 AM
My tree pannel has a itemdblclick listener that launch a function that enable to rename the node with Ext.Editor. The problem is when a node is edited , it is kept in the editor, so when another node is double clicked and renamed, the fist one is renamed also.



function renameNode(record, HTMLTarget){
editor.startEdit(Ext.get(HTMLTarget), record.get('name'));
editor.on('complete', function(me, value){
record.set('name', value);
});
}

var editor = new Ext.Editor({
field: {
xtype: 'textfield'
}
});

Ext.create('Ext.tree.Panel', {
id: 'tree',
requires: ['Ext.tree.*',
'Ext.data.*',
'Ext.Ajax.request',],
renderTo: 'tree',
width: 300,
height: 850,
header: false,
useArrows: true,
rootVisible: true,
multiSelect: true,
store: store,
listeners: {
itemdblclick: function(tree, record, HTMLTarget, i, e){
renameNode(record, HTMLTarget);
}
},
columns: [
{ xtype: 'treecolumn', header: 'Name', dataIndex: 'name', flex:2 },
{ text: 'Id', 'dataIndex': 'id', flex:1, sortable: true },
{ text: 'Type', 'dataIndex': 'type', flex:1, sortable: true },
],
});

Gary Schlosberg
10 Jun 2014, 5:58 AM
Does it work if you instantiate the editor field within your renameNode() function?

burton449
10 Jun 2014, 6:07 AM
Does it work if you instantiate the editor field within your renameNode() function?

Yes it works. I figured it out yesterday that I would have to instantiate the editor each time the function is called.

Is it how people are usually doing?