Announcement

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

    initalCriteria is not accessible in transformRequest for clientCustom data source.

    I am writing a custom data source (by defining new class and not extending anything) using dataProtocol: "clinetCustom" as suggested in the documentation and defining the transformRequest. Now I have attached this data source to a list grid with a defined initialCriteria. I don't see the initial criteria passed to dsRequest (dsRequest.data) in the transformRequest. Although the defined initial criteria is being applied on the client side automatically. I need access to the criteria to pass the filter to the server side.

    I will appreciate your quick response on this.



    #2
    Got it. I had set fetchMode to local. It's working now.

    Comment


      #3
      I am reverting back to my original question. How do I pass an initial criteria for the fetch request for data source with local fetchMode? I want this criteria to be passed to the server and it's not really a client side side criteria.

      Comment


        #4
        Depends on what you want to do. If these criteria are important for security, you want them server enforced. Using the SmartClient server, you can do this declaratively in an operationBinding, then call that operationBinding from the client via listGrid.fetchOperation.

        If you want to introduce the criteria purely client-side, you can add a dataSource.transformRequest implementation that modifies the DSRequest to add them. You can detect the specific request you want to modify by either, again, using an operationBinding and checking for operationId, or by checking the dsRequest.componentId.

        Comment


          #5
          Thanks for responding. The criteria is client side only as we are presenting same data in two different sets. I already have a custom generic data source to fetch data from some generic APIs from server. So this initial criteria is part of the grid itself. The solution I was thinking is to pass on this initial criteria object as property (with a defined key) in request properties object which then is available in dsRequest object and can be handled by custom tranformRequest generically. I wanted to check with you guys first as I have experienced that more often than not your framework already takes care of many corner cases!

          Comment


            #6
            There are a lot of ways this can be accomplished and your approach would work. But one other to consider is to call DataSource.getClientOnlyDataSource(criteria) to create a DataSource that only has a subset of the original DataSource's rows; you can then connect your grid to that.

            Comment


              #7
              DataSource.getClientOnlyDataSource(criteria) is working but issuing two requests to the server. Any idea?

              Comment


                #8
                With just that to go on, no. Try providing more information, like what the requests consist of, or ideally, how to reproduce the problem.

                Comment


                  #9
                  Running the below code from browser console for myDataSource (defined in the page), issues two XHR requests and but log only once.
                  Code:
                  myDataSource.getClientOnlyDataSource(someCrit, function(clientOnlyDS) {
                   console.log(clientOnlyDS)
                  })
                  However if I run the same code for worldDS on smartclient feature site (https://www.smartclient.com/smartcli...databoundFetch), it only issues single request.

                  Comment


                    #10
                    Unfortunately, that doesn't make it reproducible for us, and you still haven't told us anything about the requests you see.

                    Comment

                    Working...
                    X