1. #1
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
    ddrmaxgt37 is on a distinguished road

      0  

    Default Answered: Prevent Proxy from sending extra fields

    Answered: Prevent Proxy from sending extra fields


    Here is my model:




    Code:
    Ext.define('A.model.Group', {
        extend: 'Ext.data.Model',
        fields:['id', 'name'],
        proxy: {
            type: 'rest',
            url: '/group',
            reader: {
                type: 'json',
                root: 'data'
            },
            writer: {
                type: 'json',
                writeAllFields: false
            }
        }
    });
    The model is being used in a Tree via a TreeStoreThe problem is that when a PUT, POST or DELETE method is done, instead of sending only fields from the model in the JSON payload, fields from Ext.data.NodeInterface are also sent. Here is an example payload:




    Code:
    {"id":"","name":"TestGroup","parentId":"8","index":0,"depth":3,"checked":null}
    I don't want the extra fields parentId, index, depth, and checked to be sent. What is the best way to do this? I don't want to have to ignore them on the server.

  2. I don't see a pleasant way to do this. I haven't tested it but I'd imagine something like this might work:

    Code:
    Ext.define('A.model.Group', {
        extend: 'Ext.data.Model',
        fields:['id', 'name'],
        ...
    });
    
    // Looks odd but this will cause the model's prototype to have the node fields added
    Ext.data.NodeInterface.decorate(Ext.create('A.model.Group'));
    
    A.model.Group.prototype.fields.each(function(field) {
        if (field.name !== 'id' && field.name !== 'name') {
            field.persist = false;
        }
    });

  3. #2
    Sencha Premium Member skirtle's Avatar
    Join Date
    Oct 2010
    Location
    UK
    Posts
    3,573
    Answers
    540
    Vote Rating
    310
    skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future skirtle has a brilliant future

      0  

    Default


    I don't see a pleasant way to do this. I haven't tested it but I'd imagine something like this might work:

    Code:
    Ext.define('A.model.Group', {
        extend: 'Ext.data.Model',
        fields:['id', 'name'],
        ...
    });
    
    // Looks odd but this will cause the model's prototype to have the node fields added
    Ext.data.NodeInterface.decorate(Ext.create('A.model.Group'));
    
    A.model.Group.prototype.fields.each(function(field) {
        if (field.name !== 'id' && field.name !== 'name') {
            field.persist = false;
        }
    });

  4. #3
    Sencha User
    Join Date
    Aug 2011
    Posts
    5
    Vote Rating
    0
    ddrmaxgt37 is on a distinguished road

      0  

    Default


    Thanks for the response. This works. Hopefully I'll find a better way of doing this sometime.

Thread Participants: 1

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi