4 Replies Latest reply on Jun 3, 2008 6:47 AM by Gregory Lafrance

    Can you dynamically hide a datagrid?

    braseth
      I have a Flex 2 display where you search by last name, and the results populate two datagrids. Is there a way to hide a datagrid if my XML document has no results? Right now, using ColdFusion, I have the XML items set to "N/A" when there is no data. I would prefer not to display the entire datagrid w/ 4 columns of N/A if I can make it disappear somehow.

      Thanks!
        • 1. Re: Can you dynamically hide a datagrid?
          ntsiii Level 3
          Sure. If you are binding directly to lastResult, you just found another reason not to.

          Use a result handler function, and in that function, apply whatever UI logic you want, based on your data.

          Tracy
          • 2. Re: Can you dynamically hide a datagrid?
            Gregory Lafrance Level 6
            If no data is returned, as seen in the result handler function, set the datagrid "visible" property to false. You can also set "includeInLayout" property to false so the layout does not act like the datagrid is there.
            • 3. Re: Can you dynamically hide a datagrid?
              braseth Level 1
              I'm new to Flex...and I'm sure I won't get any replies to this followup, but what is a result handler?
              • 4. Re: Can you dynamically hide a datagrid?
                Gregory Lafrance Level 6
                Events are what allow Flex programs to recognize user interaction with the Flex program, and also non-user system events. Events can be user actions like clicking a button, typing text, etc., or events can be an image finishing loading, or in your case the "result" of a data request being fulfilled.

                In some cases you need to explicitly add an event "listener" to a component, such as a button, httpservice, but in other cases, you just specify a funtion that will act as the "handler" of events for the component. It is the function that will often receive the event as a parameter. Then you can look at the properties of the event object that was received as the handler parameter, and access the data, the component that dispatched the event, etc.

                Look at the following FB3 help topics for a fairly concise description of what you need to know:

                Using events
                Preventing layout of hidden controls