简体   繁体   English

拉力赛网格:仅使一列可编辑

[英]Rally Grid: Make only one column editable

Im having an issue making only one column in my grid editable. 我在使网格中的仅一列可编辑时遇到问题。 my relevant grid config is: 我相关的网格配置是:

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

I am trying to get only the 3rd column (My_Custom_Field) editable, so the user cannot change anything in columns 1 and 2. Also, The 3rd column has a combobox that only has 2 values they can choose from, so I have to set that to non-editable. 我试图仅使第3列(My_Custom_Field)可编辑,因此用户无法更改第1列和第2列中的任何内容。此外,第3列有一个组合框,只有两个可以选择的值,因此我必须进行设置不可编辑。 My Goal is that the user updates the combobox, and then the 'edit' event is fired and i save the updated record. 我的目标是用户更新组合框,然后触发“编辑”事件,并保存更新的记录。

My first issue is that I do NOT want the 'edit record cog' at the beginning of my rows, but since I have the plugin added, It won't go away. 我的第一个问题是,我不希望在行的开头添加“ edit record cog”,但是由于添加了插件,因此它不会消失。 Like I said, I ONLY want the 3rd column to be editable by the user. 就像我说的那样,我只希望用户可以编辑第三列。

Also, i get Some weird error right when I finish clicking on the combobox and selecting the values. 另外,当我单击组合框并选择值时,我得到一些奇怪的错误。 Here is a stacktrace of the error, I don't know what is null in my grid. 这是错误的堆栈跟踪,我不知道网格中的null为什么。 这是堆栈跟踪

  • To make a cell uneditable, add "editor:false" to the config of that cell. 要使单元不可编辑,请在该单元的配置中添加“ editor:false”。
  • To hide the cog, add "showRowActionsColumn:false" to the grid config. 要隐藏齿轮,请在网格配置中添加“ showRowActionsColumn:false”。
  • The error you're getting is probably related to the fact that the item isn't being properly selected for editing. 您收到的错误可能与未正确选择项目进行编辑有关。 Try removing the "enableEditing:false" config from the grid and see if that helps. 尝试从网格中删除“ enableEditing:false”配置,看看是否有帮助。

So Connor answered half of my problem, but the reason I was getting the error was because I had a renderer and an editor for the third column, and they did NOT play nicely together. 因此,Connor回答了我一半的问题,但是出现此错误的原因是因为我在第三列中有一个renderer和一个editor ,并且它们不能很好地配合使用。 I changed up the code a bit to get rid of the renderer , so I just have the editor now, and it works properly. 我稍微修改了代码以摆脱renderer ,所以我现在有了编辑器,它可以正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM