PDA

View Full Version : RowEditing does not fire any event ...



gilaras
8 Dec 2011, 3:51 AM
Hi everyone,

I'm kind of new to ExtJS (working about 2 weeks on it now) and I'm building an application to manage employees.

There only one last step missing to finish the task; i just can't update an employee.
It worked until yesterday, when I threw together different pages to one editorgrid (there were about 4 or 5 pages, which just sucked in my opinion, so I decided to redesign it :D).

I got the RowEditing plugin set up (and as I said before, when I had a single page per task, it worked fine), but when I click on "Update", the record only gets marked as dirty.
No Request or whatever is made to the server.
Here's the code for my RowEditing:


var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
clicksToMoveEditor: 1,
autoCancel: false,
listeners: function(e) {
Ext.Ajax.request({
url: '/app/aendernPage',
params: {
id : e.record.get('id'),
firstName: e.record.get('firstName'),
lastName: e.record.get('lastName'),
birthday: e.record.get('birthday'),
age: e.record.get('age'),
gender: e.record.get('gender'),
skillGroups: e.record.get('skillGroups')
},
method: 'GET',
success: function() {
Ext.MessageBox.alert("Das hat geklappt!", "Daten geändert...");
window.location.reload();
}
})

}

});

And here's the grid where I'm using it:


grid = {
xtype: 'grid',
selType : 'rowmodel',
columns: columnModel,
plugins: [rowEditing],
store: jsonStore,
id: 'grid',
forceFit: true,
height: 400,
enableColumnResize: true,
tbar:
[
{
itemId: 'createEmployee',
text: 'Erzeugen',
handler: function(e) {
win = new Ext.Window(
{
layout: 'fit',
width: 900,
height: 300,
modal: true,
closeAction: 'hide',
items: new Ext.Panel(
{
items: [inputWindow]//Your items here
})
}).show();


}
},
{
itemId: 'showAll',
text: 'Tabelle aktualisieren',
handler: function(e) {
jsonStore.load({url: '/app/ausgabeJson'});
}
},
{
itemId: 'removeEmployee',
text: 'Löschen',
handler: function(e) {
var grid = e.ownerCt.ownerCt;
var sm = grid.getSelectionModel();
var record = sm.getSelection()[0];

Ext.Ajax.request({
url: '/app/loeschenPage',
params:
{
id: record.get('id')
// firstName: record.get('firstName')
},
method: 'GET',
success: function() {
Ext.MessageBox.alert("Und tschüss...", "Mitarbeiter erfolgreich aus der Datenbank gelöscht.");
window.location.reload();
}
})

}
}
]
};

I know there may be some points to work on in general, but I want to have it up and running first :D

Can anyone tell me where my mistake is? Or what I should be doing completely different? :-?

Thanks in advance
gilaras

P.S.: If you need more information/code samples, please let me know. I'm not sure what exactly is needed to give you all the information you need ~o)

tobiu
8 Dec 2011, 4:25 AM
listeners is a config to add events, not a function directly.
http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.plugin.RowEditing-event-edit



listeners: {
edit: function(...){
...
}
}

gilaras
8 Dec 2011, 4:35 AM
Hi,

thank you very much :)
That solved my problem :)

But what I'm kind of confused about; why did it work before I merged all files into one "big" application? :-/

tobiu
8 Dec 2011, 4:42 AM
honestly, i have no clue. definining listeners with a function will never work.