1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    1
    henriqueo is on a distinguished road

      0  

    Default Unanswered: ExtJS Model URL

    Unanswered: ExtJS Model URL


    Hi guys,

    I am trying to implement a GET data from the server, but ExtJs is sending weird url, take a look:
    http://localhost:8098/rest/v1/distribution-list/1?id=1

    It shouldn't send parameter 'id', how can i remove that?

    this is my Model

    Ext.define('Wave.model.DistributionList', {
    extend: 'Ext.data.Model',
    fields: [
    {name: 'id'},
    {name: 'name', type: 'string'},
    {name: 'status', type: 'string'}

    ],

    proxy: {
    type: 'rest',
    noCache: false,
    reader: {
    type: 'json'
    },
    actionMethods: {
    create: 'POST',
    read: 'GET', // defaults to GET
    update: 'POST',
    destroy: 'DELETE'
    },
    api: {
    read: 'http://localhost:8098/rest/v1/distribution-list/',
    create: 'http://localhost:8098/rest/v1/distribution-list/',
    update: 'http://localhost:8098/rest/v1/distribution-list/',
    destroy: 'http://localhost:8098/rest/v1/distribution-list/'
    }

    }
    });

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    Answers
    3566
    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


    This has been changed in 4.1.3 and 4.2.0. By default it will not send the id parameter unless you opt in with a config.
    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.

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    1
    henriqueo is on a distinguished road

      0  

    Default


    im using 4.2.0, but I did not opt for that.
    how can i remove the 'id=1'?

    cheers

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    Answers
    3566
    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'm sorry... guess the config default changed from when it was first talked about. There is an appendId config on the Rest proxy that if you set to false should not send the id parameter.
    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
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    1
    henriqueo is on a distinguished road

      0  

    Default


    I have tried this, if appendId = false, it sends a url like this:
    http://localhost:8098/rest/v1/distribution-list?id=1

  6. #6
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    37,547
    Vote Rating
    872
    Answers
    3566
    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

      -1  

    Default


    We were chasing two different things. Remove the appendId config and to get rid of the url parameter you can try this override:

    Code:
    Ext.define('Override.data.proxy.Rest', {
        override : 'Ext.data.proxy.Rest',
    
        buildRequest : function(operation) {
            delete operation.id;
    
            return this.callParent(arguments);
        }
    });
    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.

  7. #7
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    1
    henriqueo is on a distinguished road

      1  

    Default


    It removed /1

    I´ll try to override buildUrl
    I think it should send by default /{id} when a rest proxy is chosen

    cheers

  8. #8
    Sencha User
    Join Date
    May 2008
    Posts
    27
    Vote Rating
    0
    nescha is on a distinguished road

      0  

    Default


    Code:
    Ext.override(Ext.data.proxy.Rest, {
        buildUrl: function(request) {
            delete request.params.id;
            return this.callParent(arguments);
        }
    });

  9. #9
    Sencha Premium Member
    Join Date
    Oct 2012
    Posts
    17
    Vote Rating
    0
    Answers
    2
    dwsnyder is on a distinguished road

      0  

    Default


    Shouldn't this be considered a bug? In 4.2.2.1144 it's still redundantly including the ID as a query parameter.