簡體   English   中英

拉力賽網格:僅使一列可編輯

[英]Rally Grid: Make only one column editable

我在使網格中的僅一列可編輯時遇到問題。 我相關的網格配置是:

    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列有一個組合框,只有兩個可以選擇的值,因此我必須進行設置不可編輯。 我的目標是用戶更新組合框,然后觸發“編輯”事件,並保存更新的記錄。

我的第一個問題是,我不希望在行的開頭添加“ edit record cog”,但是由於添加了插件,因此它不會消失。 就像我說的那樣,我只希望用戶可以編輯第三列。

另外,當我單擊組合框並選擇值時,我得到一些奇怪的錯誤。 這是錯誤的堆棧跟蹤,我不知道網格中的null為什么。 這是堆棧跟蹤

  • 要使單元不可編輯,請在該單元的配置中添加“ editor:false”。
  • 要隱藏齒輪,請在網格配置中添加“ showRowActionsColumn:false”。
  • 您收到的錯誤可能與未正確選擇項目進行編輯有關。 嘗試從網格中刪除“ enableEditing:false”配置,看看是否有幫助。

因此,Connor回答了我一半的問題,但是出現此錯誤的原因是因為我在第三列中有一個renderer和一個editor ,並且它們不能很好地配合使用。 我稍微修改了代碼以擺脫renderer ,所以我現在有了編輯器,它可以正常工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM