How do open a dialog on a specific position or with some kind of offset?

Hi community,

a common task is opening custom dialogs. If we open a custom dialog it´s normally positioned in the middle of the screen.

This is fine for 99% of all use cases.  But inside my dialog user can open an additional search dialog to search for target items that shall be added to a table in the main dialog.

Unfortunately the search dialog overlaps the first dialog pretty hard so users can not see the entries they add. 

Is it possible to open a dialog at a specific position at the screen? I want to display the dialog in the middle of the screen, but with an offset to give more room to the search dialog.

Even more elegant would be, if the first dialog is moved to a better position as soon user open the 2nd search dialog. But I am not sure if this is possible.

Does any one has an idea? If you know better variants for these kind of designs, please let me know!

Many thanks for any hint!

Angela

  • Hi, Angela!

    How are you show your dialogs? What functions are you use?

    If you have a reference to Dialog object it has the move(left, top) method.

  • Woohooo! That "move" tricked actually works, many thanks!

    Needed some time to understand your idea. The move function seems to be used when users move the dialog manually.

    This line moves the dialog on demand from a Method:
    parent.frameElement.dialog.move("-100");

    I am right now still test the correct values for the function. If I use any positive value, the dialog goes to the top right corner, if I use any negative value it goes to the top left. I still need some time to understand this one.

    I use a standard maximizable dialog similar to this one: https://gist.github.com/EliJDonahue/583e7a9203e553a64085ed7a4348584c

    There are no options available to specify a default position. At least not any more! I discovered that the previous outdated modal dialog even contained options for dialogTop and dialogLeft....

  • There are no options available to specify a default position. At least not any more! I discovered that the previous outdated modal dialog even contained options for dialogTop and dialogLeft....

    If you mean modalDialogHelper.show(...), i think it is not this function that is outdated now, but the information that this function is outdated. Maybe it has been rewritten since Chris published his post in 2017. if you look at the function source you will see that it uses the same ArasModules.Dialog.show(...) to create dialog and dialog.move(options.left, options.top) to set initial position under the hood.

  • I am not much into the history of dialogs, I just know that there were always a lot of dialog related changes during upgrade, especially from 11 to 12 many many years ago. 

    I assumed the code was outdated, cause I didn´t found references that still use dialogTop and left parameters.

    Anyway, specifying left and top know reliable moves the dialog. I right now trigger the movement when the additional search dialog is opened. For the trivial use case that it shall solve it´s a very good solution.

    Thanks again for your help and the insights!