Announcement

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

    Grid / TreeGrid "Search" Filter

    Hi,

    I want to implement a search filter (such a filter that instead of filtering items it highlights the matched items) - see attached pic.

    Is this possible?

    Can anyone point me to the right direction?

    thanks!

    SmartClient version : v8.3p_2013-01-21/PwerEdition Development Only
    all browsers
    Attached Files

    #2
    Hi Deddy,

    It seems you're looking for almost exactly the functionality we have built into the search box demonstrated in the Feature Explorer. As you type into the search box, this app will search through the data in the tree of examples and highlight matching entries with customized styling.

    We implemented this mechanism as a convenience class for use within the Feature Explorer and Reference Documentation viewer.
    The class in question is the "GridSearch" class, and you can see its source at the end of ExampleViewer.js if you browser the SmartClient javascript source. It works by creating a single field search form, and reacting to changes by comparing the user entered string with the data object of some grid (set up as this.grid either at init time or via a setGrid() method)

    You could certainly take this class and either work with it as is, or use it as a starting point to build your own search form functionality.
    A few comments:

    - This code has not been extensively tested against a broad range of ListGrid / TreeGrid implementations. It's internal and unsupported as it stands so we make no guarantees that it will work exactly as is with your specific grid.

    - As implemented, it uses hard-coded styling via css-text. You could of course rework this slightly to write out HTML which loads a standard css class or similar.

    Other caveats:
    - Only works on data that is already on the client

    - Can be slow on large trees because it calls getAllNodes() and uses unoptimized regular expressions. We have tested this with moderately large trees without seeing noticeable performance degradation, but you should test against your real-world use cases to ensure this isn't a problem for you.

    As a final note: If you would rather have us build this into the product as a supported component, we could do this as a feature sponsorship. Essentially this would mean we'd do some clean up and testing of the existing code, add support for obviously lacking features (such as ability to specify css highlight classes for search matches, etc), and document everything clearly. At that stage we would declare it officially supported and start accepting bug reports against any issues you encounter using it.

    Regards
    Isomorphic Software

    Comment

    Working...
    X