0
我是新來的extjs和我正面臨一個問題,我真的不明白爲什麼它不工作。我正嘗試從我的網格,其中填充網格數據庫中刪除行,但我的客戶說,沒有刪除我的服務器上(抱歉不好英語)刪除路徑未找到,存儲代理錯誤?
這裏是我的代碼:
店:
Ext.define('LU.store.Audios', {
extend: 'Ext.data.Store',
autoLoad: true,
autoSync: true,
model: 'LU.model.Audio',
proxy: {
type: 'rest',
api: {
create: 'http://localhost:3000/upload',
read: 'http://localhost:3000/list',
update: 'http://localhost:3000/update',
destroy: 'http://localhost:3000/delete'
},
reader: {
type: 'json',
root: 'audios',
totalProperty : 'total',
successProperty: 'success'
},
writer: {
type: 'json'
}
}
});
型號:
Ext.define('LU.model.Audio', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'int'},
{ name: 'name', type: 'string'},
{ name: 'path', type: 'string'}
],
});
視圖:
Ext.define('LU.view.Main', {
extend: 'Ext.panel.Panel',
alias: 'widget.mainview',
id: 'main',
initComponent: function() {
this.items = [{
}, {
xtype: 'grid',
title: 'Audio liste',
store: 'Audios',
id: 'mygrid',
columns: [
{text: 'Dateiname', dataIndex: 'name'},
{text: 'Dateipfad', dataIndex: 'path'}
],
listeners : {
afterrender : function (grid) {
grid.addDocked({
xtype: 'toolbar',
dock: 'top',
items: [{
text: 'Delete',
action: 'delete'
}, {
text: 'Download'
}]
});
}
},
}
];
this.callParent(arguments);
}
});
和控制器:
Ext.define('LU.controller.MainController', {
extend: 'Ext.app.Controller',
views: ['Main'],
stores: ['Audios'],
models: ['Audio'],
init: function() {
this.control({
'mainview button[action=delete]': {
click: this.delete
}
});
},
delete: function() {
var grid = Ext.getCmp('mygrid');
var row = grid.getSelectionModel().getSelection();
Ext.getStore("Audios").remove(row);
},
});
和服務器:
3210
感謝您的建議,只是發現了什麼問題,而我試圖改變VERB。在我的服務器上,我忘了添加「:id」到刪除路徑,所以它應該喜歡這個app.delete('/ delete /:id',function(req,res){} – Adrian