ExtJS:在Ext.grid.property.grid中显示模型
我希望在属性网格中显示持久字段(在模型文件中定义的字段) 属性网格:ExtJS:在Ext.grid.property.grid中显示模型,extjs,Extjs,我希望在属性网格中显示持久字段(在模型文件中定义的字段) 属性网格: Ext.define('ATCOM.view.InspectorProperties', { extend : 'Ext.grid.property.Grid', alias : 'widget.inspectorProperties', cls : 'property-grid', height : 150, listeners : { beforerender :
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
});
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'
}
});
我在select事件(在控制器中)中加载类似的项,其中record是我们的模型对象,getInfo()是属性网格:
var source = {};
source.id = record.get('id');
source.start = record.get('start');
source.end = record.get('end');
this.getInfo().setSource(source);
型号:
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
});
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'
}
});
是否有更好的方法来实现这一点,以便将所有非关联字段(在我的情况下,不包括分配
)自动发送到属性网格?还可以使用ATCOM.model.Shift.getFields()
读取字段,并迭代那些检查persistent:false的字段
保留剩余的键,但是如何从实例中获取类引用?例如,如何从它的一个实例中获取ATCOM.model.Shift
,以便调用getFields()
编辑:
要查找类名:可以说setSource(record.data)。我现在只是在玩这个;它似乎显示了正确的信息,但您可能无法控制要启用哪些字段进行编辑等的详细信息。是的,这里唯一的问题是,它可能会显示比
数据所需的更多信息,例如CSS类,父ID等+1用于显示如何更改列名称以及如何使其只读的代码…很好!干杯,需要一些挖掘才能找到:\