我尝试在网格面板中添加编辑按钮功能。我想在编辑按钮上打开一个编辑窗口,使用Ext Window Form更新网格行记录,其中包含(Shift名称,时间,总计,要求,注释)等字段。窗口表单已创建,但我在网格中选择的行值未在表单字段中设置。
我尝试使用此代码:
Ext.getCmp('shiftWindow').getForm().setValues(selection[0].data);
但它出现以下错误
未捕获的TypeError:无法调用未定义的方法'getForm'
这是我的代码:
var shiftWindow = Ext.create('Ext.window.Window', {
title: 'Edit Shift',
resizable: false,
id: 'shiftwindow',
width: 465, //bodyPadding: 5, modal: true, store: shiftStorePlanner,
items: {
xtype: 'form',
id: 'idFormShift',
bodyPadding: 10,
items: shiftViewModelPlannerData
},
buttons: [{
text: 'Save',
cls: 'planner-save-button',
overCls: 'planner-save-button-over',
handler: function () {
var wi = this.up('.window')
var form = Ext.getCmp('idFormShift');
if (form.isValid()) {
shiftTimemappingarray = [];
getShiftTime();
//this.up('.window').close();
}
}
}, {
text: 'Cancel',
handler: function () {
this.up('.window').close();
}
}]
});
var host1 = Ext.getCmp('plannershifteditor');
var selection = host1._shiftPlannerGrid.getSelectionModel().getSelection();
if (selection.length === 0) {
return;
}
selection[0].data.ShiftName = selection[0].data.ShiftName.replace('(ARCHIVED)', '').trim(); //if edit Archive record then text name show without (ARCHIVED)
//shiftWindow.getForm().setValues(selection[0].data);
Ext.getCmp('shiftWindow').getForm().setValues(selection[0].data);
//Ext.getCmp('shiftWindow').setValue(selection[0].data);
shiftWindow.show();
答案 0 :(得分:1)
窗口中没有getForm
方法。您可以使用shiftWindow.down('form')
获取表单。这是片段:
shiftWindow.down('form').form.setValues(selection[0].data)