No announcement yet.
  • 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 ( 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.


    • #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.


      • #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.


        • #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!


          • #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.