Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    I am using ListGrid with RestDataSource and it does not work

    I am evaluating the product and I am ready to buy an Enterprise license.
    But before, I need to be sure that the product do what I need.

    Is it possible to use a ListGrid as an answer of a complex search criteria associated with a RestDataSource.

    The listGrid will be displayed after a click on a search button.
    If I click again on the search Button, how can I change the server query via my RestDataSource?
    Is this function possible with ListGrid and RestDataSource?

    Benoît

    #2
    Absolutely you can do this. Just like with any dataSource, set the criteria on the grid and call fetchData() or pass the criteria to the fetchData() call. The criteria will arrive at your web service as GET parameters (using RestDataSource) unless you change the operationBindings.

    You can even use the built-in filtering provided by the grid. All dataSources provide this ability assuming the server knows how to do it. The Enterprise SQL datasource is super easy way to get data from existing databases without coding web services.

    Comment


      #3
      Hi davidj6,

      Do you mean that there is no way to retrieve the criteria when using POST as the operation binding?
      I am asking that because I have been able to retrieve the criteria as part of the HTTP GET parameters map. But the criteria wouldn't be accessible anymore (at least as a GET parameter) when using a POST request.
      I guess it makes sense but when using a POST request the criteria doesn't appear in the HTTP request body either, in that case the HTTP request body just contains the SmartGWT request XML.

      The result of this is that - in the context of a POST HTTP request - I have been using an additional DSRequest to pass to the server the information that I initially wanted to pass as a criteria :-/

      Where's the criteria gone when using POST HTTP requests??

      Comment


        #4
        You should be able to pass criteria for a fetch in either GET or POST messages. The body should include the criteria in POST mode. Basically anything you put in the DSRequest.data or .params is the criteria. Note that I haven't used POST for queries so I cannot confirm.

        Overriding transformRequest will allow you to put whatever additional fields you need in the message as well.

        Comment


          #5
          Well in the case of a GET request everything is fine.
          But as I said when it comes to a POST I can't figure out where the criteria has gone, hence my use of an additional DSRequest instead.
          Actually the funny thing with the DSRequest is that, even though I am using a POST request, the parameters are set in the URL and have to be accessed through the parameters map. So to summarize, the SmartGWT XML request is in the POST body as expected and the parameters of the DSRequest are in the URL parameters, as if it was a GET request. Strange... but it works.

          Thanks for you reply.

          Comment


            #6
            Note the difference between a "postParams" and "postMessage" dataProtocol in the operationBindings. Both use a POST operation but one puts data in the parameters like a GET and the other puts the data in the body.

            Comment


              #7
              Ah ok, that is interesting. Actually I just checked my code and I am using DSProtocol.POSTMESSAGE.
              Actually I now remember that initially when I was researching the docs and the forums to figure out what to do, I opted for that protocol based on the info from this page http://www.smartclient.com/smartgwt/...SProtocol.html
              I actually ruled out DSProtocol.POSTPARAMS at the time...

              I might give it a try again to see if the criteria comes up in the parameters with that one. Thanks for pointing this out.

              Comment

              Working...
              X