Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
NZFei
Partner - Specialist
Partner - Specialist

How to set a default object to a container ?

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

6 Replies
shree909
Partner - Specialist II
Partner - Specialist II

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 ..

NZFei
Partner - Specialist
Partner - Specialist
Author

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.

NZFei
Partner - Specialist
Partner - Specialist
Author

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.

Not applicable

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

Anonymous
Not applicable

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

Not applicable

Excellent Good evolution Jerry!