Announcement

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

    Question about client-side filtering

    Hi,

    i have these settings on listgrid to enable client-side filtering
    Code:
            setDataProperties(new ResultSet() {
                {
                    setFetchMode(FetchMode.LOCAL);
                    setUseClientFiltering(true);
                }
            });
    and i am calling fetch on a listgrid like this:
    Code:
        public void fetchDataForGrid(final Criteria criteria) {
            DSRequest dsRequest = new DSRequest();
            dsRequest.setData(new HashMap<String, String>() {
                {
                    put("fieldName", fieldValue);
                }
            });
    
            fetchData(criteria, null, dsRequest);
        }
    The code above is working fine for client-side filtering, but it is little bit misleading that i have to set both criteria and map to DSRequest as well.

    The problem is that i don't want to bring all the data on client with first fetch. Therefore i am setting a map in DSRequest which i passed later as a parameter for fetchData method.
    With this approach the map is taken in consideration on sever and criteria on client.

    My question is, is it possible to have client-side filtering with fetch mode set as BASIC,
    so that i don't have to set both criteria and also map to DSRequest and still use client side filtering ?

    Thanks

    #2
    We're not entirely following your description, but perhaps we can clear this up by describing exactly how things do work.

    If you have fetchMode set to "local", the first time data is fetched for the grid, a fetch is issued against the DataSource with no criteria, which causes the entire data-set to be loaded from the server.
    This complete data set is stored on the client in a cache.
    A local filter occurs to display only the records that match the criteria, and all subsequent filters will also be satisfied on the client from this cache (unless you call 'invalidateCache').

    If you have fetchMode set to "basic", the first fetch will pass criteria through to the server unchanged, and the fetched records will display in the grid.
    If the criteria changes:
    - if useClientFiltering is enabled, and the new criteria are more restrictive than the old criteria, the current set of rows is used as a cache and local filtering is performed on the client
    - if useClientFiltering is disabled, or the new criteria are less restrictive than the old criteria another fetch will occur against the server. In this case the new set of rows will again be used as a cache to filter against if new criteria are more restrictive and useClientFiltering is enabled.
    Again - invalidateCache will drop the cache and force a fetch against the server.

    If you have fetchMode set to "paged" the behavior is similar to "basic" except that the startRow/endRow of the request will be used to determine how many rows to get, so you can work with massive data sets. Obviously local filtering will not occur if you have a partial cache [in other words, 200 records match some criteria, but only 75 of them were loaded in the client].

    One additional note: if you want to have different criteria on the client from the server, you can apply additional criteria directly to the outgoing request. If you're using the SmartClient server, you might want to use an operationBinding for this, or you could use transformRequest to customize criteria explicitly in your code.
    To give a concrete example of a use case for this: Picture a dataSource containing inventory information, where some field designates location (which warehouse contains the inventory items).
    You might want to have a particular user only see records for that warehouse. This could be achieved via a custom fetch operation binding which always applied the criterion to this field on top of anything criteria specified "downstream" (from the filterEditor, for example).
    In this example, setting fetchMode to "local" would fetch all the records (with this restriction applied) from the server, and subsequent filtering would all be applied to this data set.

    Hopefully this helps. If this isn't enough information to get going, please post a more specific description of exactly what you're trying to achieve - a high level use case description and an overview of the problems with the approach you've tried.

    Regards
    Isomorphic Software

    Comment

    Working...
    X