PDA

View Full Version : Store won't sync with the database



royvanmarrewijk
19 Feb 2014, 11:34 AM
Hi,

I am trying to move a item from my dataview to another dataview with a click event. After the click event the item has to be removed from the first store and added to the second store and they both have to sync with the sql database.

The problem is that my store won't sync with my database, it doesn't even send a request to my database, and I have no idea what it could be so can you guys and girls have a look at my code:

the itemclick event:


var detailStore = Ext.StoreManager.lookup('KlokaanbodImages');

detailStore.add(record.getData());
detailStore.sync();

The model:


Ext.define('Concorde.store.KlokaanbodImages', { extend: 'Ext.data.Store',


requires: [
'Concorde.model.KlokaanbodImages',
'Ext.data.proxy.Rest',
'Ext.data.reader.Json'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'Concorde.model.KlokaanbodImages',
storeId: 'storeKlokaanbodImages',
proxy: {
type: 'rest',
url: './rest/index.php/model/klokaanbodimages',
reader: {
type: 'json',
root: 'rows'
}
}
}, cfg)]);
}
});

The Store


Ext.define('Concorde.store.KlokaanbodImages', { extend: 'Ext.data.Store',


requires: [
'Concorde.model.KlokaanbodImages',
'Ext.data.proxy.Rest',
'Ext.data.reader.Json'
],


constructor: function(cfg) {
var me = this;
cfg = cfg || {};
me.callParent([Ext.apply({
model: 'Concorde.model.KlokaanbodImages',
storeId: 'storeKlokaanbodImages',
proxy: {
type: 'rest',
url: './rest/index.php/model/klokaanbodimages',
reader: {
type: 'json',
root: 'rows'
}
}
}, cfg)]);
}
});

At this time I am only trying to insert the item into the second store.

thank you in advance,
Roy van Marrewijk

scottmartin
19 Feb 2014, 12:25 PM
Looks like you posted your store twice ..

Is your record valid?

What if you just add a record manually



store.add(
{ first_name : 'Foo' },
{ last_name : 'Bar' }
);

royvanmarrewijk
19 Feb 2014, 1:43 PM
Hi Scott,

Thank you for your quick answer! I tried your solution but it didn't worked out. I tried it with and without the 'url' field because of the convert function.

Roy

royvanmarrewijk
19 Feb 2014, 1:49 PM
Scott,

I made a mistake, you were right!:D I tried:



detailStore.add( { id: record.get('id'),
image: record.get('image'),
url: record.get('url'),
}
);


In stead of al the records seperately, it turned out that I only needed image:


detailStore.add(
{ image: record.get('image')}
);


Thank you!!!!!!!

Roy van Marrewijk