5 Replies Latest reply on Mar 25, 2008 11:00 AM by ntsiii

    Accessing hidden objects in a ViewStack.

    jfizer
      Is there a method for accessing/setting the properties of inactive objects in a ViewStack? Currently, when I try to set the dataProvider of an AdvancedDataGrid in an inactive child of the ViewStack I get a null reference error.
        • 1. Re: Accessing hidden objects in a ViewStack.
          jfizer Level 1
          Just a problem with the creation order it seems, creationPolicy=”all” fixes it. But I wouldn't mind a method that didn't require this.
          • 2. Re: Accessing hidden objects in a ViewStack.
            Garyl Woolworth Level 1
            There's no way to set a property of something that doesn't exist within memory yet, so the only two methods that are available are to A) set the creationPolicy to all so that way it loads it into memory. This can be a bad idea depending on how much it needs to create or B) develop your code so that instead of trying to set your dataProvider from outside, have the component that contains the AdvancedDataGrid pull the dataProvider, this will ensure that your AdvanceDataGrid exists, however this then leads to the problem that you have to make sure the dataProvider exists. This is easy to solve though if the dataProvider comes from a remote call. Simply have that component make the remote call and set it on result. This can also lead to a more reusable component, originally two files were required were to create a populated datagrid, keeping the methods within the component means all the first file needs to do is trigger the component and it'll do the rest on its own. Just my thoughts.
            • 3. Re: Accessing hidden objects in a ViewStack.
              ntsiii Level 3
              YES. What Kaotic says.

              Setting creationPolicy="all" is a quick "fix", but you will regret it hugely some day.

              Use binding or your own event structure to "pull" the data into the view.

              Tracy
              • 4. Re: Accessing hidden objects in a ViewStack.
                jfizer Level 1
                quote:

                Originally posted by: ntsiii
                YES. What Kaotic says.

                Setting creationPolicy="all" is a quick "fix", but you will regret it hugely some day.

                Use binding or your own event structure to "pull" the data into the view.

                Tracy


                Cant do it unfortunately. Data structure is being created at run time based on user input and external data sources. And there are a LOT of user options for configuration in the hidden and displayed data objects (charts, data grids, olap, etc). However, I should be able to force the creation of an object directly rather then making it a global change, yes?
                • 5. Re: Accessing hidden objects in a ViewStack.
                  ntsiii Level 3
                  If you can assign a data structure directly, you still can do what we advise. Create a bindable value object, and assign the data there, then bind the view to that.

                  But if you are certain, then yes, the creation policy only affects the container you set it on, not globally. Furthermore, you can manipulate the creation itself, on a component level. I don't recall any specific syntax.

                  Setting creationPolicy is sometimes ok, just be aware of the consequences.

                  Tracy