user1640256
user1640256

Reputation: 1719

Unable to edit ExtJS grid data

I am creating two grids on my view. These two grids will be able to drag and drop items from one another as well as to themselves. Also, these grids must be editable. I am using rowediting plugin to edit the grid but I always get the error "Uncaught TypeError: Cannot call method 'getSelectionModel' of undefined." Without plugin the grid works fine and I don't get any error. What is the problem? Can someone point out? The code for my grid is:

Ext.define('DHT.view.Configuration.CategoriesConfig', {
    extend: 'Ext.panel.Panel',
    requires: ['DHT.model.Category','Ext.grid.*'],
    alias: 'widget.categoriesconfig',
    layout: {
        type: 'hbox',
        align: 'stretch'
    },
    floating: true,
    closable: true,
    modal: true,
    height: 500,
    width: 800,
    title: 'Question Categories',    
    items: [{
        xtype: 'grid',
        title: 'Invisible',
        width: '47%',
        selType: 'rowmodel',   
        viewConfig: {
            plugins: [{
                ptype :'rowediting',
                clicksToEdit: 2
            },{
                ptype: 'gridviewdragdrop',
                dragGroup: 'invisible',
                dropGroup: 'visible'
            }, {
                ptype: 'gridviewdragdrop',
                dragGroup: 'invisible',
                dropGroup: 'invisible'
            }]
        },
        store: {
            model: 'DHT.model.Category',
            data: [
                { 'QuestionTypeID': 1, 'Description': 'A', 'SortOrder': 1 },
                { 'QuestionTypeID': 2, 'Description': 'B', 'SortOrder': 2 },
                { 'QuestionTypeID': 3, 'Description': 'C', 'SortOrder': 3 },
                { 'QuestionTypeID': 4, 'Description': 'D', 'SortOrder': 4 }
            ]
        },
        columns: [{
            xtype: 'actioncolumn',
            id: 'deleteButton',
            width: '5%',
            align: 'center',
            items: [{
                icon: 'Images/delete.png', tooltip: 'Delete'
            }]},
            {
                header: 'Order',
                dataIndex: 'SortOrder',
                width: '34%',
                sortable: false,
                menuDisabled: true
            },
            {
                header: 'Description',
                editable: true,
                editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    },
                dataIndex: 'Description',
                width: '58%',
                sortable: false,
                menuDisabled: true
            }]
    },
    {
        xtype: 'panel',
        title: '',
        width: '6%',
        title: ' '
    },
    {
        xtype: 'grid',
        title: 'Visible',
        selType: 'rowmodel', 
        width: '47%',
        viewConfig: {
            plugins: [{
                ptype :'rowediting',
                clicksToEdit: 2
            },{
                ptype: 'gridviewdragdrop',
                dragGroup: 'visible',
                dropGroup: 'invisible'
            }, {
                ptype: 'gridviewdragdrop',
                dragGroup: 'visible',
                dropGroup: 'visible'
            }]
        },
        store: {
            model: 'DHT.model.Category',
            data: [
                { 'QuestionTypeID': 5, 'Description': 'E', 'SortOrder': 1 },
                { 'QuestionTypeID': 6, 'Description': 'F', 'SortOrder': 2 },
                { 'QuestionTypeID': 7, 'Description': 'G', 'SortOrder': 3 },
                { 'QuestionTypeID': 8, 'Description': 'H', 'SortOrder': 4 }
            ]
        },
        columns: [{
            xtype: 'actioncolumn',
            id: 'deleteButton',
            width: '5%',
            align: 'center',
            items: [{
                icon: 'Images/delete.png', tooltip: 'Delete'
            }]},
            {
                header: 'Order',
                dataIndex: 'SortOrder',
                width: '34%',
                sortable: false,
                menuDisabled: true
            },
            {
                header: 'Description',
                editable: true,
                editor: {
                        xtype: 'textfield',
                        allowBlank: false
                    },
                dataIndex: 'Description',
                width: '58%',
                sortable: false,
                menuDisabled: true
            }]
    }]
});

My model:

Ext.define('DHT.model.Category', {
    extend: 'Ext.data.Model',
    fields: [
                {
                    name: 'QuestionTypeID',
                    dataType: 'int'
                },
                {
                    name: 'Description',
                    dataType: 'string'
                },                
                {
                    name: 'SortOrder',
                    dataType: 'int'
                }
    ],
    idProperty: 'QuestionTypeID'
});

Upvotes: 0

Views: 919

Answers (1)

Varg__
Varg__

Reputation: 134

The rowediting-plugin isn't type of the viewconfig, but a plugin of the grid itself, therefore you have to define it like this:

viewConfig: {
    plugins: [
        {
            ptype: 'gridviewdragdrop',
            dragGroup: 'invisible',
            dropGroup: 'visible'
        }, {
            ptype: 'gridviewdragdrop',
            dragGroup: 'invisible',
            dropGroup: 'invisible'
        }
    ]
},

plugins: {
    ptype :'rowediting',
    clicksToEdit: 2
},

Upvotes: 1

Related Questions