次の例では、ボタンをクリックすると、すべてのフォーム データ (両方ともKEY-VALUE
) が php ファイルに渡され、データベースに保存されます。のグラブは、ステートメントKEY-VALUE
によって行われます。var form = this.up('form').getForm();
更新 3
Ext.define ('Mycomp.model.MyClass',{
extend: 'Ext.data.Model',
fields:['textfieldone']
});
================================================== ======================
更新 2
ユーザーがボタンをクリックすると、1 つのテキスト フィールドとボタンを持つビューが表示されます (次のコードを参照)。ユーザーがいくつかの値を入力してボタンをクリックすると、ユーザーがテキスト フィールドに入力した値が DB に保存されます ( Store
PHP コードのパスへのリンクがあります)。
コントローラ
Ext.define('Mycomp.controller.MyClass',{
extend: 'Ext.app.Controller',
stores:['MyClass'],
models:['MyClass'],
views:['MyClassView'],
init: function(){
this.control({
'myclassview button[action=save]': {
click: this.myMethod
}
});
},
myMethod: function(button,record) {
var win = button.up('window'),
form = win.down('form'),
record = form.getForm().getRecord(),
values = form.getForm().getValues();
console.log (values);
console.log (record);
record.getRecord().set(values);
win.close();
this.this.getMyClassStore().sync();
}
});
見る
Ext.define('Mycomp.view.user.MyClassView', {
extend: 'Ext.window.Window',
alias: 'widget.myclassview',
initComponent: function() {
this.items = [
{
xtype: 'form',
items: [
{
xtype: 'textfield',
name : 'textfieldone',
fieldLabel: 'Contact Person Name'
}
]
}
];
this.buttons = [
{
text: 'Save',
name:'save',
action: 'save'
}
];
this.callParent(arguments);
}
});
お店
Ext.define('Mycomp.store.Myclass',{
extend:'Ext.data.Store',
model:'App.model.Myclass',
proxy: {
actionMethods : {
create : 'POST'
},
type: 'ajax',
url : '/savetodb.php'
}
});
================================================== =============================
更新 1
.... this.buttons = [
{
text: 'Save',
action: 'save'
}, ...
お店
Ext.define('Mycomp.store.Myclass',{
extend:'Ext.data.Store',
model:'App.model.Myclass',
proxy: {
actionMethods : {
create : 'POST'
},
type: 'ajax',
url : '/savetodb.php'
}
});
コントローラー
this.control({
'mycalssform button[action=save]': {
click: this.myMethod
}
});
},
myMethod: function(button, record) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
console.log (record);
console.log (values );
record.set(values);
win.close();
this.this.getmyClassStore().sync();
FIREBUG OUT PUT >> RECORD IS UNDEFINED と表示されます。どうしてこれなの ?
undefined
Object { textfileldone="hello", textfileldtwo="bever", more...}
record is undefined
[Break On This Error]
record.set(values);