我用EXTJS4的mvc模式开发,现在要修改grid的某一行提交到后台,
可是出现这个错误:uncaught exception: You are using a ServerProxy but have not supplied it with a url.
//store/Users.js
Ext.define('ERP.store.Users', {
extend: 'Ext.data.Store',
model: 'ERP.model.User',
autoLoad: false,
pageSize: 15,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: '/User/Search',
update: '/User/SaveUser'
},
reader: {
type: 'json',
root: 'rows',
totalProperty: 'totalCount',
successProperty: 'success'
}
},
initComponent: function() {
this.callParent();
}
});//controller/User.js
Ext.define('ERP.controller.User', {
extend: 'Ext.app.Controller',
stores: ['Users'],
models: ['User'],
views: ['user.Portal', 'user.List', 'user.Edit'],
init: function() {
// console.log('Initialized User! This happens before the Application launch function is called');
this.control({
'userlist': {
itemdblclick: this.editUser
},
'useredit button[action=save]': {
click: this.updateUser
},
'userportal button[action=hello]': {
click: this.hello
}
});
},
editUser: function(grid, record) {
var view = Ext.widget('useredit');
view.down('form').loadRecord(record);
},
updateUser: function(button) {
console.log('Click the save button'); var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values); this.getUsersStore().sync(); //这里应该跳到store的update:/User/SaveUser
// // this.getStore('Users').sync();//同步
win.close();
},
hello: function(button) {
alert('hello');
}
});
我在参考网站上看了,也没有成功。
<a href="http://www.sencha.com/forum/archive/index.php/t-131152.html?s=4a9332c6e5527165d7eea2c108beb981">参考地址</a>
可是出现这个错误:uncaught exception: You are using a ServerProxy but have not supplied it with a url.
//store/Users.js
Ext.define('ERP.store.Users', {
extend: 'Ext.data.Store',
model: 'ERP.model.User',
autoLoad: false,
pageSize: 15,
autoSync: true,
proxy: {
type: 'ajax',
api: {
read: '/User/Search',
update: '/User/SaveUser'
},
reader: {
type: 'json',
root: 'rows',
totalProperty: 'totalCount',
successProperty: 'success'
}
},
initComponent: function() {
this.callParent();
}
});//controller/User.js
Ext.define('ERP.controller.User', {
extend: 'Ext.app.Controller',
stores: ['Users'],
models: ['User'],
views: ['user.Portal', 'user.List', 'user.Edit'],
init: function() {
// console.log('Initialized User! This happens before the Application launch function is called');
this.control({
'userlist': {
itemdblclick: this.editUser
},
'useredit button[action=save]': {
click: this.updateUser
},
'userportal button[action=hello]': {
click: this.hello
}
});
},
editUser: function(grid, record) {
var view = Ext.widget('useredit');
view.down('form').loadRecord(record);
},
updateUser: function(button) {
console.log('Click the save button'); var win = button.up('window'),
form = win.down('form'),
record = form.getRecord(),
values = form.getValues();
record.set(values); this.getUsersStore().sync(); //这里应该跳到store的update:/User/SaveUser
// // this.getStore('Users').sync();//同步
win.close();
},
hello: function(button) {
alert('hello');
}
});
我在参考网站上看了,也没有成功。
<a href="http://www.sencha.com/forum/archive/index.php/t-131152.html?s=4a9332c6e5527165d7eea2c108beb981">参考地址</a>
type: 'ajax',
api: {
read: '/User/Search',
update: '/User/SaveUser'
},
reader: {
type: 'json',
root: 'rows',
totalProperty: 'totalCount',
successProperty: 'success'
}
},
官方文档里 上面代码放在 grid.panel中的,store里面的删了