View Full Version : Store wont save!

25 Sep 2009, 4:12 PM
Argg, pulling my hair out over here!

I have a store attached to a grid and the data loads like magic. However, all attempts to get the data to save fail!

I've tried setting the store to autoSave, I try to force a .save() on the store, nothing seems to result in a request going out (according to firebug).

Here is some of my code.. help would be much appreciated...

store[1] = new Ext.data.Store({
id: 'store_1',
proxy: new Ext.data.HttpProxy({
url: "api/ajax.php?type=competition&subtype=stats&filter=general&filter2=" + jQuery(document).getUrlParam("season") + "&attach=" + jQuery(document).getUrlParam("game")
reader: new Ext.data.JsonReader({
successProperty: 'success',
idProperty: 'number',
root: 'data'
{name: 'number', allowBlank: false },
{name: 'lastname', allowBlank: false },
{name: 'firstname', allowBlank: false },
{name: 'jersey', allowBlank: false },
{name: 'position', allowBlank: false },
{name: 'played', allowBlank: false },
{name: 'started', allowBlank: false }
writer: new Ext.data.JsonWriter({
encode: false
autoLoad: true,
listeners: {
write : function(store, action, result, res, rs) {
exception : function(proxy, type, action, options, res, arg) {
if (type === 'remote') {
msg: res.message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK

grid[1] = new Ext.grid.EditorGridPanel({
store: store[1],
clicksToEdit: 1,
columns: [
header: 'Last Name',
width: 80,
sortable: true,
dataIndex: 'lastname',
tooltip: ''
header: 'First Name',
width: 80,
sortable: true,
dataIndex: 'firstname',
tooltip: ''
header: 'CMP',
width: 50,
sortable: true,
dataIndex: 'passcmp',
tooltip: 'Completions',
editor: new Ext.form.TextField({
allowBlank: true,
tooltip: 'example tip',
listeners: {
render:function(c) {

stripeRows: true,
title:'Basic Information'

Since my extJS code is php generated it took me a while to acquire and properly format the source provided above. For that reason and other reasons, there may be parse errors in the code.

26 Sep 2009, 1:34 PM
I still cannot figure this one out. Any help would be much appreciated :\

Since posted I have discovered that the store is definately being updated with the new data from the grid. Store.modified is being populated perfectly...

However, store.save() does absolutely nothing, as far as I can tell.. even though store.writer shows what appears to be a proper writer.

writer[1] = new Ext.data.JsonWriter({
encode: true,
writeAllFields: false

in the store...

writer: writer[1],

I cant for the life of me see what the difference is between my code and the extJS examples.

Please help..

26 Sep 2009, 2:18 PM
I'd manually code the js before you get 'fancy' and have it php generated. Start simple.

27 Sep 2009, 2:32 PM

Thanks for the reply. I progressively arrived at the existing code. Every step was tested in a manual form before being generated.

But, my PHP generation isnt fancy anyway .. it simply names a few columns and things of that nature.. I can view the direct source by using "view source" .. and it all looks fine.

I only mentioned that PHP makes it difficult to post source because of the somewhat random looking indentions due to skipped \n 's here and there.

But, I am 100% confident that the fact that the code is somewhat generated has zero impact on the results.

My grids show up fine, the data is in the proper format, everything looks great. I make changes and it marks them as dirty. I then have a button attached the panel:

var save_stats_btn = new Ext.Button({
text: 'Save Stats',
disabled: false,
handler: function(){
function SaveAll() {
alert("all saved");

.. I get the alert, but in firebug no http transactions are fired. The httpProxy must be working because it loads the data exactly as it should. I use "url" (as opposed to "api") so the action itself should have an impact. Nothing is happening.

I just feel like maybe .save() isnt the proper method for forcing the store.proxy to send the data? Maybe the store is thinking nothing has changed? (even though the store.modified variable shows the proper results). I feel like I am going crazy, I cannot find anything wrong with my code :\


28 Sep 2009, 8:59 AM
Well, perhaps it is obvious to everyone else, but just in case I figured I would be a good citizen and report the problem.

I stepped through the store.save() method and noticed that one or more fields from the row were invalid due to 'allowBlank' being false.

This was not obvious to me as I figured the individual cells were validated.. but, in fact, the store validates the entire row before posting even one cell.

So, make sure that all cells validate, especially via store.fields{allowBlank} when posting data.


4 Oct 2009, 9:39 AM
how can I validate all cells in the grideditor?