Announcement

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

    Generic Datasource and client side filtering for the grid

    Hi,

    When we have a datasource which is of 'generic' type and we try to use the filtering (we want to use client side filtering), we get the "Operation type 'fetch' not supported by the DS error".

    Our aim is to fetchAll records using the DS and then use client side filtering. Even though we are having both these attributes defined in ListGrid - we get the above error.

    Can you please let me know how we can achieve clientside filtering with generic DS.

    Thanks

    #2
    Your DataSource is faulty, but you haven't shown any information about it. Please remember to post all relevant information or we will continue to be forced to bo bounce all issues back to you with requests for more information.

    Comment


      #3
      In the code you sent us, the DataSource definition has no explicitly specified dataURL.

      However you have a custom .jsp target page which handles the dataSource requests, and for your initial fetch, you're hitting this by specifying an actionURL on the actual fetch request object, like this:

      Code:
      PrdDetails_TreeGrid.fetchData({},"", {actionURL:"productOperations.jsp"});
      What you're seeing therefore is that this initial fetch hits your custom jsp end point, which services it correctly and returns a set of rows.

      You haven't set any properties that would cause this fetch to fetch all rows from the server and start caching locally -- so this fetch doesn't populate the full set of data for the grid, meaning subsequent filters / scrolling etc will issue new fetch requests automatically, and this time they will go against the default dataURL for the dataSource -- which doesn't hit your special .jsp target and so throws the "not supported" error you describe.

      To fix this
      1) Specify the 'dataURL' property on your dataSource to point to the "productOperations.jsp" page. This will ensure every fetch against the dataSource goes through your jsp logic. You can also modify your fetchData() call on the grid - no need to pass in a DSRequest config with an actionURL in this case.

      2) To get the behavior you described earlier whereby a single fetch will occur against the server and then all filtering will occur on the client, set the property "cacheAllData" to true on the dataSource.
      Note: In this case your server code will get a single request when the dataSource is defined, requesting *all* data. This is indicated by a startRow of zero and an endRow of -1 on the request.

      Comment


        #4
        thanks a lot Isomorphic. This worked.

        I just have one further clarification. As you mentioned, it needs to be set that "all" records are being fetched and then framework then takes care of the filtering. Now when we pass criteria, it would mean that maybe the results are not complete and been filtered because of the passes criteria. Am I right in saying this?

        Actually in our implementation, we have a common DS and action class in which we pass some parameter in criteria based on which we pass the complete list. Say for example Favorite List, Recent List - for which we have same method and based on the passed criteria return the appropriate result.

        Based on your suggested changes, when I don't pass any criteria it works, but that would mean I should create different action & DS for Favorite, Recent etc.

        Can there be a way where I can pass this parameter to the same method and use this same method to return different resultset?

        Thanks again for your help.

        Comment


          #5
          Not entirely sure what you're asking - are you saying that there are some criteria you need to execute on the server (the parameter that decides between "Favorite List" or "Recent List") and you would like the rest of the criteria to be executed client-side?

          Comment


            #6
            Here are the details.

            Say I have a "Favorite List" and "Recent List" - not the data for both these are in the same table and the only difference in the query would be that we would pass a Flag - Favorite = 'Y' or Recent = 'Y' based on which list we want.

            So our current implementation was that we were using same server side code, which used to get the required data using the "criteria" which user has selected (basically if user selected Favorite List we will pass listType='Favorite' in criteria or listType='Recent' in case of Recent List)

            But to enable this client filtering - I had to remove the criteria also (to make server side code return the data, I hardcoded the listType='Favorite' at server side, to let it return the Favorite list always). Which means that I will need to create different server methods for Favorite and Recent. Also since we have these defined in the dataURL I will need to duplicate my DS and just change the dataURL.

            I was thinking whether there can be a way where I can still keep my server side action generic and it fetches the results based on some flag which I pass, but the client side filtering happen - as the result passed is the entire resultset of that kind.

            Comment


              #7
              Right, so you basically want to split the criteria so that some is interpreted server-side and some on the client side.

              First of all, it may not be worth the trouble. Neither a "Favorite List" or a "Recent List" is typically a lot of data. The simplest thing might be to have a single cacheAllData:true DataSource which returns a single combined list where each record contains a property marking it as a favorite or a recent item. Then client-side filtering can select either favorites or recent items from this list via ordinary use of criteria.

              If you instead want to execute some criteria server-side and some client-side, call DataSource.fetchData() with the criteria meant for the server, and create a cacheAllData:true DataSource from the results. This DataSource will represent Favorites only or Recents only (or whatever other categories you have). Use inheritsFrom to avoid duplicating field definitions when creating these DataSources that represent only slices of the dataset.

              Comment

              Working...
              X