Boston
22 Nov 2011, 5:19 AM
Hi,
I'm new on ExtJS and try to write an app which updates a record in a Database, using a PHP backend.
I started with the MVC example on this website. Reading the data works nearly fine. I only get the notice "Store defined with no model. You may have mistyped the model name." since I'm using 4.0.7. Anyway the data is written in the grid.
After a dblclick a window with the record is opend. The record can be edited and is updated in the grid.
But when I try an update I face the error message "uncaught exception: You are using a ServerProxy but have not supplied it with a url."
I'm afraid that it is a typical mistake of an ExtJS beginner but I hope that anyone can help so that I can go forward.
Here my code:
Controller:
Ext.define('AM.controller.Haendler', {
extend: 'Ext.app.Controller',
views: [
'user.HListe',
'user.HEdit',
'user.NavTree'
],
stores: [
'Haendler'
],
models: [
'HaendlerAdr'
],
init: function() {
this.control({
'haendlerliste': {
itemdblclick: this.edithaendler
},
'edithaendler button[action=save]': {
click: this.updatehaendler
}
});
},
edithaendler: function(grid, record) {
var view = Ext.widget('edithaendler');
view.down('form').loadRecord(record);
},
updatehaendler: function(button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
win.close();
this.getHaendlerStore().sync();
}
});
Store:
Ext.define('AM.store.Haendler', {
extend: 'Ext.data.Store',
model: 'AM.model.HaendlerAdr',
autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: 'http://tools.example.com/ExtJS/php/backend.php?task=anzeigen',
update: 'http://tools.example.com/ExtJS/php/backend.php?task=aktualisieren'
},
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
}
});
Model:
Ext.define('AM.model.HaendlerAdr', {
extend: 'Ext.data.Model',
fields: ['ID','Name', 'Inhaber'],
proxy: {
type: 'ajax',
api: {
read: 'http://tools.example.com/ExtJS/php/backend.php?task=anzeigen',
update: 'http://tools.example.com/ExtJS/php/backend.php?task=aktualisieren'
},
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
}
});
Grid:
Ext.define('AM.view.user.HListe' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.haendlerliste',
width: 400,
x: 10,
y: 20,
title : 'Händler (Übersicht)',
store: 'Haendler',
collapsible: true,
collapseDirection: 'top',
titleCollapse: true,
dockedItems: [{
xtype: 'pagingtoolbar',
store: 'Haendler',
dock: 'bottom',
emptyMsg: "Keine Daten übermittelt",
displayInfo: true
}],
initComponent: function() {
this.columns = [
{header: 'ID', dataIndex: 'ID', flex: 1},
{header: 'Name', dataIndex: 'Name', flex: 1},
{header: 'Inahber', dataIndex: 'Inhaber', flex: 1}
];
this.callParent(arguments);
}
});
Window:
Ext.define('AM.view.user.HEdit', {
extend: 'Ext.window.Window',
alias : 'widget.edithaendler',
title : 'Händler bearbeiten',
layout: 'fit',
autoShow: true,
initComponent: function() {
this.items = [
{
xtype: 'form',
items: [
{
xtype: 'textfield',
name : 'Name',
fieldLabel: 'Name'
},
{
xtype: 'textfield',
name : 'Inhaber',
fieldLabel: 'Inhaber'
}
]
}
];
this.buttons = [
{
text: 'Speichern',
action: 'save'
},
{
text: 'Abbruch',
scope: this,
handler: this.close
}
];
this.callParent(arguments);
}
});
I'm new on ExtJS and try to write an app which updates a record in a Database, using a PHP backend.
I started with the MVC example on this website. Reading the data works nearly fine. I only get the notice "Store defined with no model. You may have mistyped the model name." since I'm using 4.0.7. Anyway the data is written in the grid.
After a dblclick a window with the record is opend. The record can be edited and is updated in the grid.
But when I try an update I face the error message "uncaught exception: You are using a ServerProxy but have not supplied it with a url."
I'm afraid that it is a typical mistake of an ExtJS beginner but I hope that anyone can help so that I can go forward.
Here my code:
Controller:
Ext.define('AM.controller.Haendler', {
extend: 'Ext.app.Controller',
views: [
'user.HListe',
'user.HEdit',
'user.NavTree'
],
stores: [
'Haendler'
],
models: [
'HaendlerAdr'
],
init: function() {
this.control({
'haendlerliste': {
itemdblclick: this.edithaendler
},
'edithaendler button[action=save]': {
click: this.updatehaendler
}
});
},
edithaendler: function(grid, record) {
var view = Ext.widget('edithaendler');
view.down('form').loadRecord(record);
},
updatehaendler: function(button) {
var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values);
win.close();
this.getHaendlerStore().sync();
}
});
Store:
Ext.define('AM.store.Haendler', {
extend: 'Ext.data.Store',
model: 'AM.model.HaendlerAdr',
autoLoad: true,
proxy: {
type: 'ajax',
api: {
read: 'http://tools.example.com/ExtJS/php/backend.php?task=anzeigen',
update: 'http://tools.example.com/ExtJS/php/backend.php?task=aktualisieren'
},
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
}
});
Model:
Ext.define('AM.model.HaendlerAdr', {
extend: 'Ext.data.Model',
fields: ['ID','Name', 'Inhaber'],
proxy: {
type: 'ajax',
api: {
read: 'http://tools.example.com/ExtJS/php/backend.php?task=anzeigen',
update: 'http://tools.example.com/ExtJS/php/backend.php?task=aktualisieren'
},
reader: {
type: 'json',
root: 'results',
successProperty: 'success'
}
}
});
Grid:
Ext.define('AM.view.user.HListe' ,{
extend: 'Ext.grid.Panel',
alias : 'widget.haendlerliste',
width: 400,
x: 10,
y: 20,
title : 'Händler (Übersicht)',
store: 'Haendler',
collapsible: true,
collapseDirection: 'top',
titleCollapse: true,
dockedItems: [{
xtype: 'pagingtoolbar',
store: 'Haendler',
dock: 'bottom',
emptyMsg: "Keine Daten übermittelt",
displayInfo: true
}],
initComponent: function() {
this.columns = [
{header: 'ID', dataIndex: 'ID', flex: 1},
{header: 'Name', dataIndex: 'Name', flex: 1},
{header: 'Inahber', dataIndex: 'Inhaber', flex: 1}
];
this.callParent(arguments);
}
});
Window:
Ext.define('AM.view.user.HEdit', {
extend: 'Ext.window.Window',
alias : 'widget.edithaendler',
title : 'Händler bearbeiten',
layout: 'fit',
autoShow: true,
initComponent: function() {
this.items = [
{
xtype: 'form',
items: [
{
xtype: 'textfield',
name : 'Name',
fieldLabel: 'Name'
},
{
xtype: 'textfield',
name : 'Inhaber',
fieldLabel: 'Inhaber'
}
]
}
];
this.buttons = [
{
text: 'Speichern',
action: 'save'
},
{
text: 'Abbruch',
scope: this,
handler: this.close
}
];
this.callParent(arguments);
}
});