Qlik Community

Ask a Question

QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Our next Qlik Insider session will cover new key capabilities. Join us August 11th REGISTER TODAY
cancel
Showing results for 
Search instead for 
Did you mean: 
laddu_927
Specialist
Specialist

Change the position of the objects dynamically.

Hi All,

Say I have a field test with values a,b,c...

I  have objects created with the layout condition based on the selection of the value of the list object.

Obviously, when I select random values, the objects will not be aligned. But is there a way to align the visible objects in a specific order??

Like in the image

Capture.PNG                      Capture.PNG

Please help.

1 Solution

Accepted Solutions
el_aprendiz111
Specialist
Specialist

Hi,

FUNCTION  pox(obj,x,y)

    set obj = ActiveDocument.GetSheetObject(obj)

    pos = obj.GetRect

  

    pos.Top =y

    pos.Left =x

    obj.SetRect pos

END FUNCTION

sub  move_obj

SET val=ActiveDocument.Fields("Field").GetPossibleValues(1)

  ValueToSelect = val.Item(0).Text

select case ValueToSelect

case "a"

call pox("TX01",339,47)

call pox("TX02",488,196)

call pox("TX03",636,349)

case "b"

call pox("TX01",333,349)

call pox("TX02",488,196)

call pox("TX03",644,43)

case "c"

call pox("TX01",330,196)

call pox("TX02",488,196)

call pox("TX03",649,199)

end select

END sub

View solution in original post

5 Replies
el_aprendiz111
Specialist
Specialist

Hi,

1 option:

SUB TOP_LEFT

set sh = ActiveDocument.ActiveSheet

for i = 0 to sh.NoOfSheetObjects-1

    set obj = sh.SheetObjects(i)

    pos = obj.GetRect

    pos.Top = pos.Top + 20

    pos.Left = pos.Left + 15

    obj.SetRect pos

next

END SUB

laddu_927
Specialist
Specialist
Author

Thanks for the reply,

The script only moves all the objects in the sheet by 20/15. That's it. But I need only the selected objects to align in an order. Like I should read the values of the ending of the object and align next object based on that value. Maybe we can achieve this using macro. But am very poor in VBScript and javascript.:( So expecting some help.

el_aprendiz111
Specialist
Specialist

Hi,

macro_move_txt.gif

laddu_927
Specialist
Specialist
Author

Thank you Fer, that definetly helps as a base to write some complex functionality. Can you please paste here the script??

el_aprendiz111
Specialist
Specialist

Hi,

FUNCTION  pox(obj,x,y)

    set obj = ActiveDocument.GetSheetObject(obj)

    pos = obj.GetRect

  

    pos.Top =y

    pos.Left =x

    obj.SetRect pos

END FUNCTION

sub  move_obj

SET val=ActiveDocument.Fields("Field").GetPossibleValues(1)

  ValueToSelect = val.Item(0).Text

select case ValueToSelect

case "a"

call pox("TX01",339,47)

call pox("TX02",488,196)

call pox("TX03",636,349)

case "b"

call pox("TX01",333,349)

call pox("TX02",488,196)

call pox("TX03",644,43)

case "c"

call pox("TX01",330,196)

call pox("TX02",488,196)

call pox("TX03",649,199)

end select

END sub

View solution in original post