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

StackOverflow https://stackoverflow.com/questions/2389135

  •  24-09-2019
  •  | 
  •  

문제

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":[]}
도움이 되었습니까?

해결책

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top