PDA

View Full Version : cellEditing plugin with autosync not working



anaP
29 Aug 2012, 10:44 PM
Hi,
I guess there is some small mistake I am making.
I have a store with autosync true and I am using cell editing plugin for editing grid.
after I change the cell value and click somewhere else my changes are getting lost.
what could be the reason?
here is the code..

view

Ext.define('MyApp.view.MyGridPanel', { extend: 'Ext.grid.Panel',


height: 250,
width: 400,
title: 'My Grid Panel',
store: 'MyArrayStore',


initComponent: function() {
var me = this;


Ext.applyIf(me, {
columns: [
{
xtype: 'gridcolumn',
width: 175,
dataIndex: 'AlertDescription',
editor: 'textfield',
text: 'Alert Description'
}
],
viewConfig: {


},
dockedItems: [
{
xtype: 'button',
handler: function(button, event) {
var MyArrayStore=Ext.getStore('MyArrayStore');
MyArrayStore.load();




},
dock: 'left',
id: 'mybutton',
width: 100,
text: 'MyButton'
}
],
plugins: [
Ext.create('Ext.grid.plugin.CellEditing', {
ptype: 'cellediting',
clicksToEdit: 1,
listeners: {
validateedit: {
fn: me.onGridcelleditingpluginValidateedit,
scope: me
}
}
})
]
});


me.callParent(arguments);
},


onGridcelleditingpluginValidateedit: function(editor, e, options) {
console.log(editor);
console.log(e);
console.log(options);




}


});
store

Ext.define('MyApp.store.MyArrayStore', { extend: 'Ext.data.Store',


requires: [
'MyApp.model.MyModel1'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
autoLoad: false,
autoSync: true,
storeId: 'MyArrayStore',
model: 'MyApp.model.MyModel1',
proxy: {
type: 'ajax',
url: 'data/data.json',
reader: {
type: 'array',
root: 'List'
}
}
}, cfg)]);
}
});

sword-it
29 Aug 2012, 11:46 PM
Hi,

you can see this link:http://docs.sencha.com/ext-js/4-0/#!/api/Ext.grid.plugin.CellEditing

anaP
30 Aug 2012, 2:07 AM
I checked that link..
It allows to edit but as soon as I click somewhere else it overwrites.
If I don't use auto sync and sync the store on button click then that change remains till button gets clicked.
why it is not writing new values?

vietits
30 Aug 2012, 2:54 AM
I think your problem is that you use the same url that points to static json data file for all store actions so when your store do sync with server, it allways receives the same returned results. So, ater editing a cell, your store will sync with server-side script to update new value, but what it receives back is the original data. It uses this data to update cell value. In case, your json data has more than one record, then all the modified cells will be updated with value of the first record.

anaP
30 Aug 2012, 3:48 AM
Thanks for reply..
that solves my issue I need not do ausync instead I will read it from memory and pass it to my ajax call.