Extjs throws exception “realize was called with in

2019-08-23 08:33发布

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":[]}

1条回答
干净又极端
2楼-- · 2019-08-23 09:03

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.

查看更多
登录 后发表回答