2 Replies Latest reply on Oct 28, 2008 9:27 PM by trisweb

    DataGrid custom header renderer issues

    trisweb
      I'm trying to create a DataGrid headerRenderer with a TextInput to filter the grid from the column. The custom renderer simply has a label (with the column header label) and then a text input, and it's all in AS, implementing IFactory, etc. It's rendering just fine.

      The issue is with the filtering - at first, I tried just adding the text box, but as soon as I typed anything in it, the filtering logic (which must call dataProvider.refresh() to refresh the dataGrid) caused the header to be re-instantiated, thereby clearing the filter text input field. I later worked around this by caching the TextInput objects elsewhere, and having the header simply addChild on them.

      However, the issue still gets in the way. The headerRenderer is reinstantiated twice per call to refresh(), causing it to blink, and if the user types too fast, it throws a RTE because the components haven't been instantiated yet.

      Is there a way to stop this incessant re-initialization of the headerRenderer? It doesn't seem necessary or efficient. If anyone knows or wants to help I would be very grateful. Thanks!
        • 1. Re: DataGrid custom header renderer issues
          rtalton Level 4
          This may be caused by the TextInput event you are using to call the filtering method. Are you call your filtering method from the TextInput's change event, perhaps? If so, each character being typed will call the filter method. Call your filtering method from the valueCommit event, and see if that helps.

          Put a break on the first line of your filter method, debug the app, start typing into the TextInput and watch what happens. If the filter method is called multiple times this could be the problem.

          Be sure you don't call the filter method until the typing is completed.
          • 2. Re: DataGrid custom header renderer issues
            trisweb Level 1
            That makes sense, but I had really wanted to attach it to the keyUp event so that it would filter on each keystroke. Filtering on some submit action or once the full input is complete is an acceptable compromise.