2013-12-19 109 views
0

我在我的视图上创建了两个网格。这两个网格将能够将物品从彼此以及自己拖放。另外,这些网格必须是可编辑的。我使用rowediting插件来编辑网格,但我总是得到错误“Uncaught TypeError:无法调用未定义的方法'getSelectionModel'”。没有插件的网格工作正常,我没有得到任何错误。问题是什么?有人可以指出吗?我的网格的代码是:无法编辑ExtJS网格数据

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 
      }] 
    }] 
}); 

我的模型:

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

是的,先生。同样的结果。 – user1640256

回答

1

的rowediting - 插件未键入viewconfig的,但网格本身的插件,所以你必须将它定义像这样:

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

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

是的,你是绝对正确的。我也错过了。非常感谢。 – user1640256