1. #1
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    mauricio.pacheco is on a distinguished road

      0  

    Default Unanswered: Remove "sortField" and "sortDir".

    Unanswered: Remove "sortField" and "sortDir".


    I am evaluating Ext GWT as our new tool to replace Flex and I need to disable sorting on the grid to test one of our data sources in XML. Our data source does not accept any URL query parameter not defined in the code and every time I try to load the grid in Ext GWT it adds the parameters "sortDir" and "sortField" to the URL. I tried to disable sorting on the grid and on the store using many properties and suggestions I found in blogs and docs but these parameters are always added which causes the HTTP to return 404 (Not Found). How can I remove them?

  2. #2
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Vote Rating
    21
    Answers
    20
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    How are you loading the data from the grid such that you are executing a GET request?

    All my AJAX requests using GXT to load grid data are POSTs.

  3. #3
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    mauricio.pacheco is on a distinguished road

      0  

    Default


    Thanks for the reply. You mean to say that by using POST these query parameters are not added to the URL?

  4. #4
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Vote Rating
    21
    Answers
    20
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    In short, yes. And your sort info (and filter info) will still get to, and be available from, the server.

    A more lengthy answer:

    I would argue that while there may be a use case for doing so, 99% of the time, one would not use URL parameters when using a POST and indeed, I don't know of any web browsers that will let you add add URL request parameters to any POST operation. Apparently, though, it is allowed by the HTTP spec (which was news to me) so one could theoretically do it programmatically.

    HTH,

    --adam

  5. #5
    Sencha User
    Join Date
    Feb 2012
    Posts
    3
    Vote Rating
    0
    mauricio.pacheco is on a distinguished road

      0  

    Default


    Well, modifying to POST did not change anything, the parameters "sortField" and "sortDir" are still being passed but now via POST which causes the same error. My issue is that I need to block them from being appended to the URL completely, no sorting of any kind either on the client or on the server.

  6. #6
    Ext GWT Premium Member icfantv's Avatar
    Join Date
    Sep 2011
    Location
    Superior, CO
    Posts
    411
    Vote Rating
    21
    Answers
    20
    icfantv will become famous soon enough icfantv will become famous soon enough

      0  

    Default


    They shouldn't be on the URL, they should be in the message body. Or is this what's breaking your code?

    If you don't want them sent at all, the only way I can think of shutting it off is to execute the call and update the list store manually. If you're using any type of load config (paging or filter) these are going to be sent.

    Alternatively, and this solution just doesn't feel right, you may be able to add a request filter to your filter chain and call HttpServletRequest.removeAttribute(...). But again, this solution doesn't feel right. Also, I think this will only work for a POST as there doesn't seem to be a way to remove parameters.

  7. #7
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    The HttpProxy takes a writer instance that decides how to serialize the data to a string, and put it on the url. By default, the UrlEncodingWriter iterates over all properties and adds them as url parameters.

    It is possible to write a custom DataWriter that will take a config object, and write out only the values you need to the url string, in the format you desire. Assign this to the HttpProxy (or any proxy that passes a string to the server), and it will use that to turn the config into data.

  8. #8
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    34
    Vote Rating
    0
    Answers
    1
    MarcT is on a distinguished road

      0  

    Default


    I must be doing something wrong because my HttpProxy does not have a default UrlEncodingWriter. Instead, I just get toString called on the PagingLoadConfig, which spits out the class name. I'm really confused because the PagingGrid example obviously works, but I don't see any writer set there. And I've searched all the source. How can I get this working?

  9. #9
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Sorry, I might not have been clear.

    The HttpProxy takes a writer instance that decides how to serialize the data to a string, and put it on the url. By default, the UrlEncodingWriter iterates over all properties and adds them as url parameters.
    That said, HttpProxy does not have a default instead of UrlEncodingWriter - without one, it must default to trying to .toString() the config data passed in. UrlEncodingWriter doesn't have a constructor that HttpProxy can invoke, because generics don't allow it to know what config Class<?> instance to use, or what AutoBeanFactory. Additionally, there are use cases (especially when using HttpProxy with POST) where UrlEncodingWriter won't make sense.

    PagingGridExample, at http://staging.sencha.com:8080/examp...ace:paginggrid uses RpcProxy, which sends the config object to the server using RPC, not using url parameters. AdvancedComboBox uses a ScriptTagProxy, which is similar to HttpProxy, and sets a UrlEncodingWriter - this can be seen at http://sencha.com/examples-dev/#Exam...vancedcombobox along with source.

  10. #10
    Sencha Premium Member
    Join Date
    Dec 2011
    Posts
    34
    Vote Rating
    0
    Answers
    1
    MarcT is on a distinguished road

      0  

    Default


    Thanks, Colin, that makes more sense. I was able to get the UrlEncodingWriter working with the HttpProxy by referring to the AdvancedComboBox example.

    I really hope you have some awesome documentation about the data binding coming with the full release of GXT 3. All the flexibility and power has created a massively steep learning curve and it's really hard to figure out which parts of the various examples are applicable to my situation.