Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    37
    Vote Rating
    1
    rfox is on a distinguished road

      1  

    Question Use a field other than 'id' for server calls?

    Use a field other than 'id' for server calls?


    Apologies if this has been asked before its hard to search for

    Given a model/store with a defined and working proxy, how do i configure it so it does not submit server calls using id.

    For example say i have a server side file representing Cars eg(data/cars.json) and i want to load car 3:
    Code:
    model.load(3,success...fail...etc
    Firebug always shows my browser as requesting data/cars.json?id=3.

    What if i wanted it to use 'carid' eg data/cars.json?carid=3?

    Is this possible? I've looked into using the idProperty field in a model but it is either ignored or that's not what it actually does.

    I believe what i want is similar to the mapping property that you can define in a writer except for reading.

  2. #2
    Sencha User
    Join Date
    Oct 2011
    Location
    Sweden
    Posts
    36
    Vote Rating
    0
    JambaFun is on a distinguished road

      0  

    Default


    Hi rfox,

    This one is so ugly that I'm not even sure I want to post it, but close inspection of Ext.data.Model, Ext.data.proxy.Server and Ext.data.proxy.Ajax only gave one possible solution:
    Code:
    model.load(false, {
        params: {carid: 3}
    });
    Best Regards

  3. #3
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    37
    Vote Rating
    1
    rfox is on a distinguished road

      0  

    Default


    That's really anoying, id is a reserved cgi variable in both POST and GET for the server side software im using. Pretty much everywhere I want to load data I cannot use ID as its parameter.

    The definition of idProperty on the docs is also confusing . Looks like it only affects the internal storage of the model.

    Thanks for your input

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    35,704
    Vote Rating
    750
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    I have moved this to the bugs forum and entered as a bug as the idProperty should change the parameter that is sent back. This isn't a bug per-say but an improvement.
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Touch Premium Member
    Join Date
    Oct 2011
    Posts
    37
    Vote Rating
    1
    rfox is on a distinguished road

      0  

    Default


    Thanks for moving it to bugs its good to know its been acknowledged

  6. #6
    Sencha User
    Join Date
    Jun 2010
    Location
    Buenos Aires, Argentina
    Posts
    213
    Vote Rating
    9
    ldonofrio will become famous soon enough

      0  

    Default


    same problem here, loose 1 day trying to override this and nothing

  7. #7
    Sencha User VDP's Avatar
    Join Date
    Feb 2012
    Location
    Boom, Belgium
    Posts
    79
    Vote Rating
    9
    VDP will become famous soon enough

      0  

    Default


    good one @JambaFun => use undefined instead of false and the id param won't be sent.

    My solution is based on your idea:

    Code:
    Ext.define('MyApp.model.MyModel', {
        extend: 'Ext.data.Model',
    
        idProperty: 'code',
        fields: [
            {
                name: 'code'
            },
            {
                name: 'version',
                type: 'int'
            },
            {
                name: 'content'
            }
        ],
        proxy: {
            type: 'ajax',
            api: {
                read: BCS.API_URLS.preference.load,
                update: BCS.API_URLS.preference.save,
                create: BCS.API_URLS.preference.save
            },
            reader: {
                type: 'json',
                root: 'rows',
                messageProperty: 'message'
            }
        }
    }, function(model){
    
    
        var parentLoad = model.load;
    
        model.load = function(id, config) {
            config.params = config.params || {};
            config.params[model.prototype.idProperty] = id;
            Ext.callback(parentLoad, this, [undefined, config]);
        };
    
    
    });

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar