Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
210
Trying to create a search or find function
posted

So I'm trying to figure out how I could go about writing a function that will look through the content of the cells and look for matches against a certain find string.  Ideally, this would highlight the cells in which the match is found.

Now, I've been working with the grid for a couple weeks and have created a rather nice converter class that is used by the CellValuePresenter to take the value of a given cell and construct the presentation content using a Label (I'm also looking into some readonly RichTextBoxes here and there, but that should be beside the point).  It all works like a charm, and I'm able to easily set formatting on individual fields, even those in the same column. 

As such, if I know the search value before the grid renders a given cell, then it works like a charm.  The problem is that this is supposed to be dynamic.  In other words, if I have a grid showing a bunch of records, and I change the search string and say "Find it", all the prior highlighting needs to go away and new highlighting applied to the matching cell values.

I've tried iterating through the records in the grid and for each field in each record, grabbing the CellValuePresenter for it (using FromRecordAndField) and changing the background color appropriately.  The problem (as I've seen in other postings) is that simply changing the properties of the presenter doesn't cause it to re-render.

If the presentation change was based upon some change to the underlying data (currently, I'm binding to a datatable), then I presume that it WOULD rerender the cell.  Barring that I'm not sure how to force/trick/coax it into doing what I want.

Any ideas?

Parents
No Data
Reply
  • 210
    posted

    A few more notes on this one: as might be obvious, if I haven't scrolled a record into view yet, then the highlighting is correct on new records as I page through the grid.  Also, if I scroll a bum row out of view and wait a little bit, when I scroll it back, the cell presenter fires off again and it highlights it correctly.

    So the only problem for me is how to get that to happen for records that are currently in view.  I see that in past versions there have been a number of tricks to do this (setting the visibility on records to hidden/collapsed and back), but then updates cause those tricks to no longer work.

    So Infragistics: is there an intended, "official" way of doing this?  Of invoking the CellValuePresenter's rendering logic programmatically?

Children
No Data