Skip to content Skip to sidebar Skip to footer

Extjs 5.0 Model Post Values Not Received On Server Side (working Extjs 4.2)

I am upgrading our Extjs 4.2 app to Extjs 5.0. I am able to bring up all the read only pages but i am getting issues when i try to update/save the data. I will really appreciate yo

Solution 1:

The problem here is that you try to fool the Ext. You create new record with id - normally ids are assigned by the server. Therefore, you need to commit it to clear it phantom (new record) flag, so that Ext thinks it is already existing record. But, after commit, the record has no modified fields and, by default, only modified fields are sent to the server. Therefore, you need a writer configured, something like this:

Ext.define('MyApp.model.User', {
    extend: 'Ext.data.Model',
    idProperty: 'id',
    fields: [
        {name: 'id', type: 'int'},
        {name: 'userName', type: 'string'},
        {name: 'country', type: 'string'}
    ],

    proxy: {
        type: 'rest',
        url : 'success.php',
        listeners: {
            exception: function(proxy, response, operation) {
                Ext.Msg.alert('Failed', 'Save the user Failed!');
            }
        }
        ,writer:{
             type:'json'
            ,writeAllFields:true
        }
    }
});

Post a Comment for "Extjs 5.0 Model Post Values Not Received On Server Side (working Extjs 4.2)"