dimanche 18 janvier 2015

How to get a blank string for a new model instance's idProperty?

I have the following model which, under Ext JS 4.x, would result in a blank string (or null, I think) for the 'code' field when creating a new model instance:

Code:



Ext.define('App.model.TrainingCode', {
extend: 'Ext.data.Model',
requires: [
'Ext.data.field.String'
],
idProperty: 'code',
fields: [
{
type: 'string',
name: 'code'
},
{
type: 'string',
name: 'classification'
}
]
});

How do I achieve this behaviour in Sencha Architect 3.1 with Ext JS 5.0.1? It is linked to a REST store so I can't set the blank string myself when I create the record (which I'm stuffing into a grid and using a row editor), because doing so results in a PUT and not a POST. Setting the idProperty value on creating a new model makes it no longer a phantom record, so I'm in a nasty catch-22 with these new auto-generated rubbish values for idProperty fields. I just want null or a blank string.



How to get a blank string for a new model instance's idProperty?

Aucun commentaire:

Enregistrer un commentaire