PDA

View Full Version : AJAX proxy does not react on Store changes what is missing?



Tsukasa
10 Jul 2012, 11:06 AM
Hello,

I have a Grid, a Store and Model for its data and AJAX proxy for the Store that is pointing to my self-written PHP back-end. The PHP backend writes to log each time it is called.

The system works OK for Read, Update and Delete calls. However now I need to add new field to Store, which I do in such a way:



(here, some new data were generated...)

var newEntry=Ext.ModelManager.create({
id:id,
title: title,
url: '/php/'+fname,
minithumb: '/php/'+small,
thumb:'/php/'+thumb
}, 'MyApp.model.fileListModel');
var store=Ext.getCmp('currGallery').getStore();
store.add(newEntry);
store.sync();


I have the new line appearing in the Grid.
But with or withour sync() call, I have no calls going to my PHP back end. It however reads one more time. Store has parameter autoSync :true and does great updating data automatically when I edit existing line in the Grid.

What am I missing?

Farish
10 Jul 2012, 11:58 AM
If you want the record you are adding to be treated as a new record, set the phantom property of that record to true. If you want the record to be treated as an updated record, set the dirty property of the record to true.


record.phantom = true;

and then add it to your store. If the record already has a valid id and is not a phantom, the store doesnt think that its a new record.

According to docs, Ext.ModelManager.create is deprecated. It is recommended to use Ext.create instead.

Ext.ModelManager.create

Tsukasa
10 Jul 2012, 12:08 PM
Worked like a charm. Thanks!