morony morony - 14 days ago 6
reST (reStructuredText) Question

ExtJs deleting element from store doesn't work

I'm working with ExtJs 6.2.0 and Java Spring MVC for the REST API.
I'm trying to delete an object from one of my store but I'm having a problem : instead of using my id named

idCamp
, extjs is using the field named
id
that contains an extjs generated id (for example:
extModel47-1
).

I'm working on the delete part but I didn't try to update a camp nor fetch one, but I think the configuration is the same for these three operations that need the id.

Here is my store:


Ext.define('XXXXXX.store.Camps', {
extend: 'Ext.data.Store',
alias: 'store.camps',
model: 'XXXXXX.model.Camp',
fields: [
'idCamp', // More irrelevant fields
],
autoLoad : true,
autoSync: true,
storeId: 'storeCamp',
proxy: {
type: 'rest',
idParam: 'idCamp',
url: // irrelevant,
reader: {
type: 'json',
rootProperty: 'data'
},
writer: {
type: 'json'
}
}
});


Here is my model:


Ext.define('XXXXXX.model.Camp', {
extend: 'Ext.data.Model',
idProperty: 'idCamp',
fields: [
{ name: 'idCamp', type: 'int' },
// More irrelevant fields
]
});


I also tried to put an idProperty inside the writer/reader inside the proxy but it didn't do anything.

Forgive my poor usage of the English language since I'm a French people.

Best regards,
Morony

Answer

The issue is using a combination of fields/model in your store definition. They are in competition with each other. Remove the fields definition.