PDA

View Full Version : Set treecolumn value before edit



tzalberto
26 Jun 2013, 8:55 AM
Hi all,

I'm using treepanel with treecolumn to represent a File/Folder Tree Structure. My panel looks like:



var mypanel= Ext.create('Ext.tree.Panel', {
id: 'mypanel',
store: mystore,
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1
})
],
columns: {
items: [
{
xtype: 'treecolumn',
text: 'File Structure',
dataIndex: 'text',
editor: {
allowBlank: false
}
}
]
}
});


The 'text' field in mystore contains the name of the file/folder including extension.
When the user clicks on the filename, the column allows to edit it.

My problem is that when the user clicks to edit I need to show in the editor only the filename without the extension.

For example:
File: myfile.txt
The editor should only show myfile

How can I achieve this?

I have no problem with splitting the string to get the name and the extension. The problem is to configure the editor to show only the name. I tried to do it through the beforeedit event of the treepanel but I couldn't get it.

slemmon
27 Jun 2013, 9:57 PM
See if this example helps to get you going in the right direction:



var store = Ext.create('Ext.data.TreeStore', {
fields: ['text'],
root: {
expanded: true,
children: [
{ text: "myfile.txt", leaf: true }
]
}
});


Ext.create('Ext.tree.Panel', {
title: 'Simple Tree',
width: 200,
height: 150,
store: store,
rootVisible: false,
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
clicksToEdit: 1,
listeners: {
beforeedit: function (editor, c) {
c.value = c.value.substring(0, c.value.indexOf('.'));
},
edit: function (editor, c) {
c.record.set(c.field, c.value + '.txt');
}
}
})
],
columns: {
items: [
{
xtype: 'treecolumn',
text: 'File Structure',
dataIndex: 'text',
flex: 1,
editor: {
allowBlank: false
}
}
]
},
renderTo: Ext.getBody()
});

WPriyanka
21 Sep 2017, 10:00 PM
Hi slemmon, i have same requirement i have text and then anchor tag i want to put only text without anchor tag in texteditor. I tried doing it in beforeedit as u provided but still editor take value from record. Is there any workaround for this?Thanks in advance.

vick_44
26 Sep 2017, 1:02 AM
@WPriyanka , It would help if you can paste your code snippet that you have tried over here, Or even better, on a new thread.