PDA

View Full Version : Problem with RowEditor 3.3 Press Cancel but page fire the POST Request to server



cdavide75
3 Dec 2010, 3:46 PM
Hi,
I use RowEditor with RestFul like in this example http://dev.sencha.com/deploy/dev/examples/restful/restful.html
My page is a EditorGridPanel with RowEditor plugin, server side I work with asp net mvc
My Page work fine... delete, load, update record... all ok !

But sometimes (no always... this is the stenge) when I go to edit e row and then press Cancel button the Page fire the request post to server ... as like as I press OK.

Sometimes No but sometimes Yes... why?

this my code:

var WaitMask = new Ext.LoadMask(Ext.getBody(), {msg:"Please wait..."});

var record = Ext.data.Record.create([
{ name: 'idMoneta' },
{ name: 'Descrizione' },
{ name: 'Sigla' }
]);


var store = new Ext.data.Store({
restful: true,
api: {
create: 'Anagrafiche/Monete/Create',
read: 'Anagrafiche/Monete/Load',
update: 'Anagrafiche/Monete/Update',
destroy: 'Anagrafiche/Monete/Delete',
},
reader: new Ext.data.JsonReader({
root: 'data',
idProperty: 'idMoneta'
}, record),
writer: new Ext.data.JsonWriter({
encode: false,
writeAllFields: true
}),
autoSave: true,
listeners: {
exception: function (proxy, type, action, options, res, arg) {
WaitMask.hide();
//if (type === 'remote') {
store.rejectChanges();
alert(type);
Ext.Msg.show({
title: 'REMOTE EXCEPTION',
msg: res.raw.message,
icon: Ext.MessageBox.ERROR
});
//}
}

,beforewrite: function (proxy, type, action, options, res, arg) {
WaitMask.show();
}
,write: function (proxy, type, action, options, res, arg) {
WaitMask.hide();
}
}
});


var cm = new Ext.grid.ColumnModel({
// specify any defaults for each column
defaults: {
sortable: false // columns are not sortable by default
},
columns: [new Ext.grid.RowNumberer(), {header: 'Descrizione', allowBlank: false, dataIndex: 'Descrizione',width: 130, editor: new Ext.form.TextField()} , {header: 'Sigla',dataIndex: 'Sigla',width: 70,editor: new Ext.form.TextField()}]
});

var editor = new Ext.ux.grid.RowEditor({
saveText: 'Update'
});

var grid = new Ext.grid.EditorGridPanel({
store: store,
cm: cm,
loadMask: true,
frame: true,
height: 800,
renderTo: 'editor-grid',
tbar: [{
icon: '<%= Url.Content("~/Scripts/ext/resources/images/default/grid/refresh.gif")%>',
text: 'Refresh',
handler: function (b, evt) { store.load(); }
}, {
icon: '<%= Url.Content("~/Scripts/ext/resources/images/default/dd/drop-add.gif")%>',
text: 'Add',
handler: function(){
var e = new record();
editor.stopEditing();
store.insert(0, e);
grid.getView().refresh();
grid.getSelectionModel().selectRow(0);
editor.startEditing(0);

}

}, {
ref: '../removeBtn',
disabled : true,
icon: '<%= Url.Content("~/Scripts/ext/resources/images/default/dd/drop-no.gif")%>',
text: 'Delete',
handler: function (b, evt) {

var rec = grid.getSelectionModel().getSelected();
if (!rec) {
return false;
}
grid.store.remove(rec);

}
}
],
sm: new Ext.grid.RowSelectionModel({singleSelect:true}),
plugins: [editor]

});

grid.getSelectionModel().on('selectionchange', function(sm){
grid.removeBtn.setDisabled(sm.getCount() < 1);
});


store.load();

I use extjs 3.3, last roweditor plugin (include in extjs 3.3 archive)

Can anybody help me

Thanks and "FORZA" EXTJS ;-)
D

Condor
4 Dec 2010, 12:58 AM
What kind of request is this? An update request?
And which parameters have changed according to that request?

cdavide75
5 Dec 2010, 9:24 AM
Hi, Condor
I SOLVE my problem!! :-)
I used EditorGridPanel... now I use GridPanel

In my code change only EditorGridPanel with GridPanel and now all is OK!

I hope this my experience can help other people

Thanks
Davide