在 ext 4 中从控制器中选择网格的第一条记录
我正在尝试选择网格的第一行。然而,以下给了我
“视图未定义”
onLaunch: function () {
var partsStore = this.getPartsStore();
partsStore.load({
callback: this.onPartsLoad,
scope: this
});
},
onPartsLoad: function (selection) {
var grid = Ext.getCmp('partsViewGrid');
grid.getSelectionModel().select(0);
var form = Ext.getCmp('partForm');
form.loadRecord(selection[0]);
},
我的观点
Ext.define('Pandora.view.PartsList', {
extend: 'Ext.grid.Panel',
alias: 'widget.partslist',
store: 'Parts',
initComponent: function () {
this.id = "partsViewGrid";
this.height = 400;
this.xtype = 'gridpanel';
this.border = 0;
this.columns = [
{
xtype: 'gridcolumn',
id: 'description',
dataIndex: 'Name',
text: 'Descriptfion'
},
{
xtype: 'gridcolumn',
id: 'done',
dataIndex: 'Completed',
text: 'Done',
renderer: renderProduct
}
];
this.callParent();
}
});
I'm trying to select the first row of my grid. However the following gives me
"views is undefined"
onLaunch: function () {
var partsStore = this.getPartsStore();
partsStore.load({
callback: this.onPartsLoad,
scope: this
});
},
onPartsLoad: function (selection) {
var grid = Ext.getCmp('partsViewGrid');
grid.getSelectionModel().select(0);
var form = Ext.getCmp('partForm');
form.loadRecord(selection[0]);
},
My view
Ext.define('Pandora.view.PartsList', {
extend: 'Ext.grid.Panel',
alias: 'widget.partslist',
store: 'Parts',
initComponent: function () {
this.id = "partsViewGrid";
this.height = 400;
this.xtype = 'gridpanel';
this.border = 0;
this.columns = [
{
xtype: 'gridcolumn',
id: 'description',
dataIndex: 'Name',
text: 'Descriptfion'
},
{
xtype: 'gridcolumn',
id: 'done',
dataIndex: 'Completed',
text: 'Done',
renderer: renderProduct
}
];
this.callParent();
}
});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果您只想要一条记录,则不需要其中的数组“selection[0]”。在 ExtJs 4.x 中,这对我来说总是有效:
If you just want one record you don't need the array "selection[0]" in there. In ExtJs 4.x this always works for me: