Results 1 to 4 of 4

Thread: Set treecolumn value before edit

  1. #1
    Sencha User
    Join Date
    Dec 2012
    Posts
    19
    Answers
    1
    Vote Rating
    0
      0  

    Default Set treecolumn value before edit

    Hi all,

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

    Code:
    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.

  2. #2
    Sencha User slemmon's Avatar
    Join Date
    Mar 2009
    Location
    Boise, ID
    Posts
    6,165
    Answers
    505
    Vote Rating
    253
      0  

    Default

    See if this example helps to get you going in the right direction:

    Code:
    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()
    });

  3. #3
    Sencha User
    Join Date
    Mar 2017
    Posts
    8
    Vote Rating
    0
      0  

    Default

    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.

  4. #4
    Sencha User vick_44's Avatar
    Join Date
    Jul 2016
    Posts
    45
    Answers
    4
    Vote Rating
    4
      0  

    Default

    @WPriyanka , It would help if you can paste your code snippet that you have tried over here, Or even better, on a new thread.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •