以下に、2 つのフィールドを持つ Ext.form.Panel があります。モデルで、データを持つ 2 つのランダム フィールドを選択しました。それらはフォームにレンダリングされていません。このコードでは、Extjs フレームワークで MVC を使用していないことに注意してください。 これらのフィールドをレンダリングするにはどうすればよいですか? store.data.toSource() からの関連する出力を貼り付けて、実際にストアにデータがあり、レコードが 1 つしかないことを示しました。もう少し大きな解像度で画像を表示するには、画像を右クリックして別のタブで表示します。
注: .toSource() は Mozilla Firefox でのみ機能します
フォームを作成した後にこれを実行しようとしましたが、うまくいきませんでした:
taskForm.getForm().loadRecord(store.getAt(0));
コード:
var taskForm = Ext.create('Ext.form.Panel', {
title: 'Task',
id: 'form1',
width: 600,
height: 200,
bodyPadding: 10,
renderTo: 'TaskEditForm',
store: store,
style: {
'position': 'fixed',
'top': '100px',
'left': '10px'
},
items: [{
xtype: 'label',
labelAlign: 'right',
name: 'project_id',
fieldLabel: 'Project ID',
width: 100
}, {
xtype: 'label',
labelAlign: 'right',
name: 'user_responsible',
fieldLabel: 'User',
width: 100
}],
buttons: [{
text: 'Save Task Detail',
handler: function (btn) {
alert(store.data.toSource());
}
}]
});
========
編集:@エヴァン
このコードでは、以下のエラーが発生します。
taskForm.getForm().loadRecord(store.getAt(0));
エラー:
TypeError: record is undefined
...
return this.setValues(record.data); // ext-all-debug.js (line 109529)
行 109529:
loadRecord: function(record) {
this._record = record;
return this.setValues(record.data);
},