2

我有一个问题,使我的网格中只有一列可编辑。我的相关网格配置是:

    me.FeatureGrid = me.add({
        xtype: 'rallygrid',
        width: 700,
        height:300,
        scroll:'vertical',
        columnCfgs: [
            {
                text:'Feature', 
                dataIndex:'Name',
                width:400
            },{
                text:'Stories', 
                dataIndex:'ObjectID',
                sortable:true, 
                doSort: function(direction){
                    //custom sort function
                },
                width:100,
                renderer:function(oid){
                    //custom render funciton
                }
            },{
                dataIndex:'My_Custom_Field',
                width:180,
                text:'Status',                  
                editor:{
                    xtype:'combobox',
                    store: Ext.create('Ext.data.Store', {
                        fields: ['Status'],
                        data:[
                            {'Status':'Committed'},
                            {'Status':'Not Committed'}
                        ]
                    }),
                    editable: false,
                    displayField: 'Status'
                },
                renderer: function(tcs, meta, record){
                    //render function
                }
            }
        ],
        plugins: [
            Ext.create('Ext.grid.plugin.CellEditing', {
                clicksToEdit:1
            })
        ],
        viewConfig:{
            stripeRows:true
        },
        listeners: {
            beforeedit: function(editor, e){
                console.log(e.colIdx);
                return e.colIdx === 3; //only edit last col
            },
            edit: function(editor, e){
                //edit function
            }
        },
        showPagingToolbar:false,
        enableEditing:false,
        context: this.getContext(),
        store: //feature Store
    }); 

我试图只让第 3 列 (My_Custom_Field) 可编辑,因此用户无法更改第 1 列和第 2 列中的任何内容。此外,第 3 列有一个组合框,只有 2 个值可供选择,所以我必须设置它到不可编辑。我的目标是用户更新组合框,然后触发“编辑”事件并保存更新的记录。

我的第一个问题是我不想在行的开头出现“编辑记录齿轮”,但由于我添加了插件,它不会消失。就像我说的,我只希望用户可以编辑第三列。

此外,当我完成单击组合框并选择值时,我得到了一些奇怪的错误。这是错误的堆栈跟踪,我不知道null我的网格中有什么。 这是堆栈跟踪

4

2 回答 2

3
  • 要使单元格不可编辑,请将“editor:false”添加到该单元格的配置中。
  • 要隐藏 cog,请将“showRowActionsColumn:false”添加到网格配置中。
  • 您收到的错误可能与未正确选择该项目进行编辑有关。尝试从网格中删除“enableEditing:false”配置,看看是否有帮助。
于 2014-07-21T20:13:47.267 回答
2

所以康纳回答了我一半的问题,但我得到错误的原因是因为我在第三列有 arenderer和 an editor,而且它们不能很好地结合在一起。我稍微修改了代码以摆脱 . renderer,所以我现在只有编辑器,它可以正常工作。

于 2014-07-22T15:32:05.630 回答