Reputation: 57
In ExtJS 6.5.0, I've created a Store and a editable gridpanel:
Ext.define('StateStore',{
extend: 'Ext.data.Store',
alias: 'store.stateStore',
storeId : 'StateStore',
fields: ['Id', 'Name', 'SortIndex'],
autoLoad : true,
proxy: {
type : 'ajax',
api : {
create : undefined,
read : '/kanban/states/read/' + kanbanId,
update : '/kanban/states/update/' + kanbanId,
destroy : undefined
},
writer : {
type : 'json',
allowSingle : false
}
}
});
var StateList = Ext.create({
xtype : 'gridpanel',
selModel: 'cellmodel',
title : 'Manage States',
store : {
type: 'stateStore'
},
plugins: {
ptype: 'cellediting',
clicksToEdit: 1
},
columns: [
{
text: 'ID',
dataIndex: 'Id',
flex: 1
},{
text: 'Name',
dataIndex: 'Name',
flex: 2,
editor: {
field: {
type: 'textfield',
allowBlank: false
}
}
},
{
text: 'SortIndex',
dataIndex: 'SortIndex',
flex: 1,
}
],
});
When user finish editing and click save, store.sync() function will be called, but it will only pass the modified records and fields to the server. I use record.dirty=true
to force it pass all records, but the unmodified fields still not passed.
Why I want to pass all the records and fields? Because I'd like to remove the existing records and create new records every time it updates. So I don't need to deal with create/update/delete separately. There will be only a few entries, so performance is not a problem.
One solution is use Ext.Ajax()
instead of sync()
, I wonder is there a better solution?
Upvotes: 0
Views: 1690
Reputation: 30082
Configure your writer with writeAllFields: true
.
Relevant docs.
Upvotes: 4