6 Replies Latest reply: May 27, 2015 11:07 AM by Enrique Laura RSS

    How to set a default object to a container ?

    Fei Xu

      Hello,

      Say there are several objects / reports in one container. Every time when opening this sheet, I want the container to show a fixed object. How can I achieve that please? Thanks!

       

      Fei

        • Re: How to set a default object to a container ?
          sree anaarasi

          hi, in container object whichever u selected the recent one chart or something else , will show up once u open the container object.

          if u want to keep anything default then make that chart selected ..

            • Re: How to set a default object to a container ?
              Fei Xu

              Different users come to a same container, they select different charts, then they leave and save. Next time when other user open the document and come to the container, charts are different. What I want is every time when a document is opened, all the containers will show pre-defined charts. Even users do some changes and leave and save. 

              Anyone know how to do that using Macro please? Thanks.

            • Re: How to set a default object to a container ?
              Fei Xu

              Someone has created a Idea http://community.qlik.com/ideas/2437 but is there any work around to achieve it now? How do to it in trigger?

               

               

               

              I found if  you click the link above, it goes to unexpected error page. If you copy and paste it to IE, then it goes to correct idea page.

              • Re: How to set a default object to a container ?

                For setting the default index of the container when opening the document, create a new action as follows.

                 

                1. In the main menu, go to Settings\Document Properties

                 

                2. In the Document properties window, go to the Triggers tab, click on the OnOpen option in the Document Event Triggers window and click on the Edit Action button.

                 

                3. In the Actions window, add a new External\Run Macro action and then enter the macro name SetContainerIndexDefault

                 

                Use this macro for setting the default index. Note that you must replace "CT06" with the Object Id chosen to be the default in your container.

                 

                sub SetContainerIndexDefault

                 

                Set ContainerObj= ActiveDocument.GetSheetObject("CT06")

                Set ContainerProp=ContainerObj.GetProperties      

                ActiveChartIndex=0

                ContainerProp.SingleObjectActiveIndex = ActiveChartIndex

                ContainerObj.SetProperties ContainerProp

                 

                 

                End Sub

                 

                 

                Default_index_container.PNG.png

                  • Re: Re: How to set a default object to a container ?
                    Jerry Somsen

                    Thanks for the hint.   I was able to add a little to your code and loop through all objects and set all containers to default to the first object.

                     

                    SUB SetContainerDefault

                    'This Subroutine sets all the Container Objects to make the first object in the container active.

                    'This will run on the on open command and on close command.

                    'Assumes that all Container Object Ids start with a CT

                    Objects = ActiveDocument.ActiveSheet.GetSheetObjects

                    For i = lBound(Objects) To uBound(Objects)

                         IF LEFT(Objects(i).GetObjectId,11) = "Document\CT" THEN 

                              SET ContainerProp = Objects(i).GetProperties 

                              ActiveChartIndex = 0 

                              ContainerProp.SingleObjectActiveIndex = ActiveChartIndex

                              Objects(i).SetProperties ContainerProp   

                         END IF

                    next

                    end sub