Results 1 to 9 of 9

Thread: ExtJS Model URL

  1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    9
    Vote Rating
    1
      0  

    Default 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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Answers
    3899
    Vote Rating
    1270
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Answers
    3899
    Vote Rating
    1270
      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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
      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 - Sr Software Engineer mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    39,416
    Answers
    3899
    Vote Rating
    1270
      -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 @LikelyMitch
    Sencha Inc, Senior Software Engineer
    ________________
    Learn BBCode and use it!

    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
      1  

    Default

    It removed /1

    Ill 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
      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
    19
    Answers
    2
    Vote Rating
    0
      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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •