0

i am using checkboxmodel plugin for a checkbox column.But, what i want is that 'if i check a column some cells of that row will be editable'...i searched a lot but no luck.I am working with MVC pattern and because of the plugin i dont know how to handle it

/**Grid View**/

    plugins: [
        Ext.create('Ext.grid.plugin.CellEditing', {
            clicksToEdit: 2
        })
    ],
    selType: 'cellmodel',
    selModel: Ext.create('Ext.selection.CheckboxModel', {
        checkOnly: true,
        listeners: {
            selectionchange: function(model, records) {
                if (records[0]) {
                    //make any cell of a field editable
                }
            }
        }
    }),
    {
        header:'name',
        dataIndex:'name'},
        {
            header:'Quantity',
            dataIndex:'quantity',
        }

here if i check any row i want to make the grid's quantity field editable...This would be nice if someone can help...

Molecular Man
  • 22,277
  • 3
  • 72
  • 89
Mir Gulam Sarwar
  • 2,588
  • 2
  • 25
  • 39

1 Answers1

1

Try this:

1) create editor plugin instance for reference:

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

2) use this instance in grid plugin definition:

plugins: [
        editor
    ]

3) modify your selModel definition to look something like this:

selModel: Ext.create('Ext.selection.CheckboxModel', {
        checkOnly: true,
        listeners: {
            selectionchange: function(model, records) {
                if (records[0] && !editor.editing) {
                    editor.startEdit(records[0], 2);    // 2 is the number of column you want to edit
                }
            }
        }
    }),

Using this solution you will be able to edit only one cell when grid row is checked. Also you will need to implement additional logic to stop editing previously edited cell in case if selection change etc... Hope this hint will help you.

the_virt
  • 707
  • 4
  • 10
  • because of the mvc pattern where should i declare the var Editor – Mir Gulam Sarwar Jun 11 '13 at 09:59
  • Actually it is not necessary to create editor variable outside. You may use: Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 2, pluginId:'celledit' }); then in selectionchange event: var editor = model.view.ownerCt.getPlugin('celledit'); – the_virt Jun 11 '13 at 11:05
  • what will be in the model.view.ownerCt – Mir Gulam Sarwar Jun 11 '13 at 11:43
  • it will be reference to Ext.grid.Panel object – the_virt Jun 11 '13 at 12:01
  • There is no 'out of the box' way to edit multiple rows. You will need to search/implement multiple row editor yourself. I would implement own Ext.grid.plugin.Editing subclass based on sources of Ext.grid.plugin.CellEditing making it able to edit multiple cells at once. – the_virt Jun 13 '13 at 09:16