I'm using ExtJS 6.5 to create a grid with a combobox in toolbar. The combobox have a store bound in a specific viewmodel. When selecting an option, the grid will refresh(POST) with a beforeload listener in the viewmodel's store, by adding an extraparam to the store proxy. Which works fine.
But, when i'm trying to edit one record bound to the grid, even thou before the request (PUT) the record looks fine, when record.save() the extraparam will be sent as a parameter of the record.
The code looks something like this:
items:[
{
xtype: 'grid',
bind: {
store: '{gridstore}'
},
tbar: [
{
xtype: 'combobox',
fieldLabel: false,
reference: 'some_selection',
width:100,
bind: {
store: '{cat}'
},
listeners: {
change: 'reloadStore'
}
}
],
columns: [
{
dataIndex: 'name',
text: 'Name',
align: 'left',
flex: 1,
minWidth: 150
},{
dataIndex: 'soemthing',
text: 'Something',
align: 'left',
flex: 1,
minWidth: 150
}]}
The viewmodel:
stores: {
gridstore: {
model: 'Model',
listeners: {
beforeload: function (store){
var category = Ext.ComponentQuery.query('[reference="some_selection"]')[0],
category_value = category.value;
store.getProxy().extraParams = {
category: category_value
}
}
}
},
cat: {
fields: ['cat'],
data: [
['One'],
['Two'],
['Three'],
['Four'],
['Five']
]
}
}
On edit:
view.add({
xtype: form_panel,
modal: true,
viewModel: {
data: {
currentRecord: record
}
}
});
On save:
record.save({
success: function(response, operation) {
console.log(response)
}
});
I found an workaround by removing the extraparam on load listener on store:
load: function (store) {
if (!store.isLoading())
delete store.getProxy().getExtraParams()['category'];
}
I know the record's store have the extra parameter, but why is it sent when saving the record?
question from:
https://stackoverflow.com/questions/65937378/extjs-6-store-extraparam-propagated-into-record-on-save