我想在属性网格中显示持久字段(在我的模型文件中定义的字段).

属性网格:
Ext.define('ATCOM.view.InspectorProperties', {
extend : 'Ext.grid.property.Grid',
alias : 'widget.inspectorProperties',
cls : 'property-grid',
height : 150,
listeners : {
beforerender : function() {
// Rename the first column
var cols = this.getView().getHeaderCt().getGridColumns();
cols[0].setText("Property");
},
beforeedit : function(e) {
// Read-only
return false;
}
},
source : {} // Start with no items
});
Run Code Online (Sandbox Code Playgroud)
我在select事件(在控制器中)加载这样的项目,其中record是我们的模型对象,getInfo()是属性grid:
var source = {};
source.id = record.get('id');
source.start = record.get('start');
source.end = record.get('end');
this.getInfo().setSource(source);
Run Code Online (Sandbox Code Playgroud)
模型:
Ext.define('ATCOM.model.Shift', {
extend : 'Ext.data.Model',
fields : [ 'id', {
name : 'start',
type : 'date',
}, {
name : 'end',
type : 'date',
}, 'position', 'controller' ],
hasMany : {
model : 'ATCOM.model.ShiftAlloc',
name : 'allocations'
}
});
Run Code Online (Sandbox Code Playgroud)
有没有更好的方法来解决这个问题,所以所有非关联字段(allocations在我的情况下都不包括)会自动发送到属性网格?也许可以读取字段ATCOM.model.Shift.getFields()并迭代那些检查persistent:false;以保留剩余的键,但是如何从实例获取类引用 - 例如,如何ATCOM.model.Shift从其中一个实例获取以便我可以调用getFields()?
编辑:
用于查找类名:http://docs.sencha.com/ext-js/4-1/#!/api/Ext.Base-static-method-getName