1. #1
    Ext User
    Join Date
    May 2009
    Posts
    2
    Vote Rating
    0
    Andrea_P is on a distinguished road

      0  

    Default [SOLVED] [3.0rc1.1] Writer problem

    [SOLVED] [3.0rc1.1] Writer problem


    Hi,
    I'm new to Ext.. I wrote the following code:

    Code:
        store = new Ext.data.Store({
            url: "-----.php",
            baseParams: {limit:100},
            remoteSort: true,
            reader: new Ext.data.JsonReader({
                    totalProperty: "totalCount",
                    root: "records",
                    idProperty: "id",
                    successProperty: "success"
                },Keyword
            ),
            writer: new Ext.data.JsonWriter({
                    returnJson: true,
                    writeAllFields: false
                },Keyword
            )
        }),
    When I update the row with the writer I send from the server this:

    Code:
    {"success":true}
    But I have this error:

    DataReader#update received invalid data from server. Please see docs for DataReader#update

    what's wrong?? Thanks

    Andrea

  2. #2
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    89
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default


    A writer update should return an object with the new record values.

  3. #3
    Ext User
    Join Date
    May 2009
    Posts
    2
    Vote Rating
    0
    Andrea_P is on a distinguished road

      0  

    Default


    solved returning this:

    Code:
    {"success":true,"records":{"id":"2694",....}}
    thanks!

  4. #4
    Ext JS Premium Member christocracy's Avatar
    Join Date
    Oct 2006
    Location
    Montreal
    Posts
    381
    Vote Rating
    0
    christocracy is on a distinguished road

      0  

    Default


    Andrea, you don't have to return the entire record but you must return at least the id. The DataReader will merge any incoming new data from server with existing data on the record. However, I think it's always a good idea for the server to re-assert its authority over the data on the client.

    Quite often, one might have a grid with an "Updated at" column. You'd want that column to be refreshed after each update. See thumb.
    Attached Images
    /**
    * @author Chris Scott
    * @business www.transistorsoft.com
    * @rate $150USD / hr; training $500USD / day / developer (5 dev min)
    *
    * @SenchaDevs http://senchadevs.com/developers/transistor-software
    * @twitter http://twitter.com/#!/christocracy
    * @github https://github.com/christocracy
    */

Thread Participants: 2