나는 extjs about adding a form on click의 자습서를 따르려고합니다.Sencha ext.js, 즉석에서 양식 만들기
이제 "비틀기"는 좀 더 구조화 된 접근 방식을 직접 만들고 싶습니다. 그래서 나는 그리드와 폼을 생성하기 위해 Ext.define
을 사용하고있다.
그리드 :
Ext.define('MyApp.view.main.EmployeeGrid', {
extend: 'Ext.grid.Grid',
xtype: 'employee-grid',
title: 'Employee Directory',
iconCls: 'x-fa fa-users',
listeners: {
itemtap: function() {
console.log("test");
Ext.create("MyApp.view.main.FormPanel", {});
}
},
store: {
data: [{
"firstName": "Jean",
"lastName": "Grey",
"phoneNumber": "(372) 792-6728"
}]
},
columns: [{
text: 'First Name',
dataIndex: 'firstName',
flex: 1
}, {
text: 'Last Name',
dataIndex: 'lastName',
flex: 1
}, {
text: 'Phone Number',
dataIndex: 'phoneNumber',
flex: 1
}]
});
형태 :
Ext.define("MyApp.view.main.FormPanel", {
extend: "Ext.form.Panel",
xtype: 'form-panel',
title: 'Update Record',
floating: true,
centered: true,
width: 300,
modal: true,
items: [{
xtype: 'textfield',
name: 'firstname',
label: 'First Name'
}, {
xtype: 'toolbar',
docked: 'bottom',
items: ['->', {
xtype: 'button',
text: 'Submit',
iconCls: 'x-fa fa-check',
handler: function() {
this.up('formpanel').destroy();
}
}, {
xtype: 'button',
text: 'Cancel',
iconCls: 'x-fa fa-close',
handler: function() {
this.up('formpanel').destroy();
}
}]
}]
});
문제가있는 코드가 MyApp.view.main.EmployeeGrid
클래스의 listeners: ...
을 받고있다. 콘솔에 항목이 기록되므로 함수가 실행되었음을 알 수 있습니다. 그러나 양식이 표시되지 않습니다. - 올바른 접근 방법은 무엇입니까?
답장을 보내 주셔서 감사합니다. 작성한 내용에 실수를 한 것으로 나타났습니다. 물론 "MyApp.view.main.FormPanel"(내 원본 게시물을 업데이트해야 함)이어야합니다. - 그러나 "좋은"해결책을 사용하려고하면, 다음과 같은 오류가 발생합니다 :'잡히지 않은 TypeError : this.myForm.loadRecord는 함수가 아닙니다' – paul23
@ paul23 나는 당신이 현대적으로 달리고 있다는 것을 간과했습니다. 그들은 그것들을 ['setRecord'] (http://docs.sencha.com/extjs/6.2.1/modern/Ext.form.Panel.html#method-setRecord)라고 부릅니다. 내 경험에 비추어 볼 때, 고전적인 것과 현대적인 문제는 전체 개발 과정에서 여러분을 기다릴 것입니다. – Alexander