开发者

Extjs throws exception "realize was called with invalid remote-data" on successful creation of record

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/Creat开发者_StackOverfloweBar.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":[]}


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜