Scroll to a certain view

  • 9 March 2021
  • 6 replies
  • 116 views

Hi, 

 

Is there a way to navigate in your form to a certain place. Something like Focus on view x. I have a large form and when I press a certain button I want to scroll all the way up again. I do see action “go to a view” but it doesn't seem to do anything (at least I see nothing happening). 

 

Kind regards, mark


6 replies

Hi @MdenHeijer,

 

There is a Focus option you can use:
 

You can have a hidden control at the top of your view, and use the “Execute a View Control Method” on your button click rule and select the hidden control from your view (the focus method should be there already).

Hope this helps, Let me know if you have any questions :)

 

Kind Regards

Prineel

Badge +9

You can achieve this by using a simple tweak. 

When you want to focus on a certain view,

In the Actions tab you can use Execute a Control’s method / Execute a View’s Control Method, select the view and select the first control in that view, and from the method select Focus.

 

Thanks,

 

Regards,

Vijay.

Hi Vijay / Prineel, 

I have tried that, and the scroll bar moves about 1 cm but doesn't go to the top where the control is located. It doesn't seem to properly work. (my form has 14 views on them, of which 3 unique on top, then 10 duplicates and one 1unique at the bottom. I have tried both choosing a control on a unique view on top or the first of the duplicates, but no matter which control I choose, it gives me the same result)

 

Regards, 

Mark

Hi @MdenHeijer,

That is weird. I tried to create a similar scenario, but did not have any issues. I have a couple suggestions:
If you have not used button controls to focus on, then perhaps try using buttons (toolbar or normal button controls)
 

Pershaps try using the “Go to View” rule first, then use the “Execute a View Control Method” and see is that works

It seems like it does not work with hidden controls (or at least on my environment for some odd reason). Will do some further testing

 

Kind Regards

Prineel

Hi @MdenHeijer,

 

Are your controls hidden?

 

Kind Regards

Prineel

Badge +9

Hi Mark,

That is the only OOB rule available to do this.

But if you are OK to use script  in your form then you can write some Javascript function to focus that control and execute that function when it is required. 

 

Inserting Javascript on the K2 smartforms

https://vijaydk2guy.wordpress.com/2017/06/02/basic-jqueryjavascript-samples-in-smart-forms/


Javascript Code to focus on a control below
https://developer.mozilla.org/en-US/docs/Web/API/HTMLOrForeignElement/focus

 

Thanks,

Regards,

Vijay.

Reply