PDA

View Full Version : Bulk Update in extjs



saksudesh
30 Jul 2015, 9:41 PM
Hello,

I want a single update button on header and the cell editing in the grid and when I change the cell values and click on the single button on the header it should save into the database,how to achieve this?

chamacs
31 Jul 2015, 7:44 AM
I think you're asking about controlling the store's sync capability. If you config the store.autoSync : false and on button click do a store.sync() it will batch/send all changed records to the server as one transaction.

To clarify store.sync():
- All 'new' records are batched and sent together
- All 'updated' records are batched and sent together
- All 'deleted' records are batched and sent together

The store.sync() sequentially sends each of the above transactions (I don't remember the order). If any fail, the sync stops.

Hope this helps.

wilfogn
3 Aug 2015, 1:34 PM
This is an example of how to configure a store for such a sync.


var patients = Ext.create('Ext.data.JsonStore', {

model: 'patient',
autoLoad: false,
proxy: {
api: {
read: '/patients/get_patients',
update: '/patients/save_patients',
destroy: 'patients/delete_patients'
},
actionMethods: {
read : 'POST',
update : 'POST',
destroy : 'POST'
},
noCache: true,
simpleSortMode: true,
timeout: 60000,
type: 'ajax',
reader: {
root: 'data',
totalProperty: 'total'
},
writer: {
root: 'data',
type: 'json',
encode: true
}
},
sorters: {property: 'name', direction: 'ASC'}