views:

753

answers:

1

I am using extjs in a monorail application. I am using a JsonStore to persist data back to my controller. I have read, update and delete working properly. But I cannot seem to figure out how to format my response back on creates. Currently, Firebug gives me the following error:

uncaught exception: Ext.data.DataReader: #realize was called with invalid remote-data. Please see the docs for DataReader#realize and review your DataReader configuration.

I am flummoxed about WTF this error means. Anyone have pointers? Relevant bits of code below:

 var proxy = new Ext.data.HttpProxy({
        api: {
            read: '../foo/bar.rnr',
            create: '../foo/CreateBar.rnr',
            update: '../foo/UpdateBar.rnr',
            destroy: '../foo/DeleteBar.rnr'
        }
    });

    var writer = new Ext.data.JsonWriter({
        encode: true,
        writeAllFields: true,
        listful: true,
        destroyRecord: function(rec) {
            return this.toHash(rec);
        }
    });


    var store = new Ext.data.JsonStore({
        autoLoad: true,
        autoSave: false,
        url: '../foo/bar.rnr',
        method: 'get',
        baseParams: { Id: pageParameters.Id },
        proxy: proxy,
        writer: writer,
        id: 'Id',
        fields: [
            { name: 'Id', type: 'int' },
            { name: 'Name', type: 'string' },
            { name: 'Note', type: 'string', defaultValue: null }

        ]
    });

My current response looks like this, but this is after a lot of trial and error, so it is prolly hosed.

{"success":true,"message":"OK!","undefined":[]}
+2  A: 

You'll need to return records in the returning json object.

Go to the following example from My book, Ext JS in Action, that shows how to use data writer for crud actions.

http://extjsinaction.com/examples/chapter08/usingWriterWithHttpProxy.html

Right click to insert a new record. Observe the Ajax req's from firebug and you'll see it in action.

Jay Garcia
thats exactly what I needed thanks! book == purchased.now
NotMyself
An accepted answer *and* a sale!
Jonathan Julian