Hybrid View

  1. #1
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    0
    sundoggie is on a distinguished road

      0  

    Default Unanswered: possible to create a custom filter, using an IdentityValueProvider?

    Unanswered: possible to create a custom filter, using an IdentityValueProvider?


    I've got a custom cell, that writes output from an IdentityValueProvider, e.g. takes the whole model, looks at a couple of properties, and renders the cell content.

    I want to also user a GridFilter. Have tried to create my own custom filter, similar to the StringFilter, and I'm able to actually enter text to filter on, but appears the Store (TreeStore in this case) is unable to compare the text to the property (or properties) of the model returned by the IdentityValueProvider. Are there examples of doing this? The Sencha examples pretty much use the basic value providers, e.g. String & Date.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    GridFilters is a class that represents a collection of Filter<T> objects, each of which describe both how to draw the filter, and how to perform it. The Filter base class is designed to be able to pass these filters off to the server in the form of FilterConfig (if you are using RPC, it'll be the FilterConfigBean impl), describing what property, what value, and how to compare. In the case of IdentityValueProvider, the default property is the string "", representing the object itself.

    It is also able to pass off filter details to the store on the client (either TreeStore or ListStore) in the form of a StoreFilter. The StoreFilter interface has a single method which describes whether or not this filter wants a given item to be visible - the default behavior is that if any filter removes an item, it shouldn't be visible (exception: in TreeStore, if a child is visible, then the parent and all of its parents must be visible). The AbstractGridFilters class takes care of building this based on details within the Filter - specifically validateModel(M).

    If you implement your own Filter<T> and override the methods discussed here - validateModel, getType, getValue, getFilterConfig, you'll be sure to work correctly whether you are performing the actual filter operation on the server or on the client. Building the UI is then taken care of by setting the Filter.menu field with whatever you want drawn. Take a look at some of the existing filters for how these can be used to implement your desired behaviors.

    There are no constraints on the types that can be filtered - your IdentityValueProvider is just another ValueProvider as far as these are concerned. That said, as discussed above, you may need to work to build a particular UI component that correctly indicates to the user how they can search for items, as well as how to actually perform the search.

  3. #3
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    15
    Vote Rating
    0
    sundoggie is on a distinguished road

      0  

    Default


    thanks, this helps a great deal. The comment on the true purpose of validateModel, is what I was missing....I had actually removed it, not understanding what it was doing. Now that I have it, my custom filter actually works! Not to complain, a little bit of additional javadoc comments, like what you've written here, in the Filter base class, and/or in the StringFilter class, would have gotten me much farther along...

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,734
    Vote Rating
    90
    Answers
    109
    Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light Colin Alworth is a glorious beacon of light

      0  

    Default


    Thanks for the feedback - I'll see about cleaning up this text and getting it added to the Filter JavaDocs.

Thread Participants: 1