我正在使用带有 ruby on rails 的 ext js 设计器。我想在按钮单击事件中从我的网格和数据库中删除一条记录。谁能帮我?谢谢...
以下是我的网格的代码。
xtype: 'grid',
title: 'Products',
store: 'productMaster',
height: 176,
id:'mygrid',
name:'mygrid',
sm: new Ext.grid.RowSelectionModel({
singleSelect: true,
listeners: {
rowselect: function(sm, row, rec) {
Ext.getCmp("myform").getForm().loadRecord(rec);
}
}
}),
columns: [
{
xtype: 'gridcolumn',
dataIndex: 'name',
header: 'name',
sortable: true,
width: 100
},
{
xtype: 'gridcolumn',
dataIndex: 'price',
header: 'price',
sortable: true,
width: 100
},
{
xtype: 'gridcolumn',
dataIndex: 'category',
header: 'category',
sortable: true,
width: 100
},
以下是我的删除按钮代码
bbar: {
xtype: 'toolbar',
height: 30,
items: [
{
xtype: 'button',
text: 'Delete',
width: 100,
height: 30,
id:'btnDelete',
handler: function() {
//alert('trying to delete the record...');
var store = Ext.getCmp("mygrid").getStore();
store.removeAt(store.getCount()-1);
}
由于这个处理函数,最后一条记录 id 被删除,但它是从存储中删除的,而不是从数据库中删除的。我也希望从数据库中删除记录...
谢谢...