PDA

View Full Version : Nested records state change only after key event.



olivierpons
12 Apr 2012, 6:50 AM
Hi,

Before explaining my problem, it's important to say that I'm using my overriden JSON writer object for nested records you can find here (http://www.sencha.com/forum/showthread.php?141957-Saving-objects-that-are-linked-hasMany-relation-with-a-single-Store&p=765331&viewfull=1#post765331).

I've done a "main" grid, with a form linked to this grid.

In this form, there's a nested grid which is linked to a nested field of the "main" grid.

Like this:

33922

I've added the possibility to add another attribute: "Ajouter un attribut" means "Add an attribute".

When the users clicks on this button, I've made a selection on it:

33923

If you validate, it works perfectly, and it's sent to the server, with all the fields included. I'm using the property "writeAllFields: true" to send it automatically.

So, once it's sent, I've added a listener that brings back to the "updated" record, with this function storeAfterWrite. So this code:


var storeAfterWrite = function(proxy, operation) {
if ( (operation.action == 'create') ||
(operation.action == 'update') ) {
/* go to the record */
var m = this.getById(
parseInt(operation.resultSet.records[0].internalId)
);
}
else if (operation.action == 'destroy') {
/* Go to first record : */
var m = this.getAt(0);
}
if (m) {
/* select record : */
this.panelGridEtEdit.gsGrid.getSelectionModel().select(m);
}
else {
/* make sure nothing is selected */
this.panelGridEtEdit.gsGrid.getSelectionModel().deselectAll();
}
Ext.example.msg(
Ext.String.capitalize(operation.action),
operation.resultSet.message
);
};

Here's the declaration of storeProduits.


var storeProduits = Ext.create('Ext.data.Store', {
model: 'Intranet.Produit',
autoLoad: true,
autoSync: true,
proxy: {
... blabla ...
},
listeners: {
write: storeAfterWrite
}
});


It's added, and there's no problem:


33924


But the damn weird thing is that, after adding something into a the nested list, as long as I click with the mouse on a record of the "main" grid, everything works fine, but if I move with the keyboard (arrow keys up and down), the nested list appears like this:




33925

Do you know where this could come from, and where I should look?

Once again, NB: I'm using my overriden JSON writer object for nested records you can find here (http://www.sencha.com/forum/showthread.php?141957-Saving-objects-that-are-linked-hasMany-relation-with-a-single-Store&p=765331&viewfull=1#post765331).

mitchellsimoens
13 Apr 2012, 7:41 AM
Are you talking about the red triangles? If so that just means the records weren't commit() after changing the data.