PDA

View Full Version : Adding an new record to json reader



Weicheng.Huang
12 Nov 2013, 8:46 AM
Hi,

I can add to the gird panel, however it always shows the the 12312331. Even, the alert msg shows 88888888. I have json writer & reader in my store. When I reload the store, nothing new record exits.

Initial data:
12312331
12312332
12312333

View:

var casestore = Ext.getStore('Localexpand'); // get store
var model = Ext.ModelManager.getModel('MyApp.model.LocalModel'); //get model
var record = new Ext.create( model );
record.set('ID', '88888888');
alert(record.get('ID'));
casestore.add( record );
casestore.commitChanges( );

Store:

model: 'MyApp.model.LocalModel',
storeId: 'Localexpand',
pageSize: 5,
proxy: {
type: 'ajax',
url: 'local2.json',
reader: {
type: 'json',
root: 'RetrieveInfo'
},
writer: {
type: 'json',
root: 'RetrieveInfo'
}
}

Model:

fields: [
{
name: 'ID'
}
]

Weicheng.Huang
12 Nov 2013, 7:53 PM
First, you have to unchecked auto-syn on the store. Then, you will get the correct value and show on the grid. However, someones say it's not possible to write to the local json file because of security issue. Or using the ajax.request.


Hope someone provide some useful advice.