[英]ExtJs Ext.grid.Panel access model from column
In Ext.grid.Panel when user changes checkbox's state, I need to save the model that represents this row. 在Ext.grid.Panel中,当用户更改复选框的状态时,我需要保存代表该行的模型。
I have this code (very simplistically, because this component is very big): 我有以下代码(非常简单,因为此组件很大):
Ext.define('Hts.Appointments.List.Grid', {
extend : 'Ext.grid.Panel',
initComponent : function() {
this.store = /* Big initialization code for store */
this.columns = [{
header: Hts.Localization.APPOINTMENTS.HIGHLIGHT,
dataIndex: 'highlighted',
xtype: 'checkcolumn',
flex: 1,
listeners: {
checkchange: function(column,rowIndex,checked) {
/* Here I need to access the model and save it */
}
},
/* other columns */
]
}
})
I hope I provided enough information (I'm very new in ExtJs). 我希望我提供了足够的信息(我在ExtJs中是新手)。
define your model with an id, using property 'idProperty'. 使用属性“ idProperty”使用ID定义模型。
Ext.define('Model', {
extend: 'Ext.data.Model',
idProperty: 'idProp',
fields: [
{ name: 'id', type: 'int' },
{ name: 'name', type: 'string' }
]
});
you can get the model and save it with: 您可以获取模型并将其保存:
listeners: {
checkchange: function(column,rowIndex,checked) {
var model = Ext.ModelManager.getModel('idProp'); // access
model.save(); //save
}
},
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.