[英]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
為什么。
因此,Connor回答了我一半的問題,但是出現此錯誤的原因是因為我在第三列中有一個renderer
和一個editor
,並且它們不能很好地配合使用。 我稍微修改了代碼以擺脫renderer
,所以我現在有了編輯器,它可以正常工作。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.