MdenHeijer
Apprentice

Scroll to a certain view

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

Tags (3)
0 Kudos
Reply
6 Replies
Prineel
Scout

Re: Scroll to a certain view

Hi @MdenHeijer,

 

There is a Focus option you can use:
 

be6b7d66-113c-4f1d-b6ed-43b32f9c0bd2.png
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

0 Kudos
Reply
VJay
Scout

Re: Scroll to a certain view

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.

0 Kudos
Reply
MdenHeijer
Apprentice

Re: Scroll to a certain view

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

0 Kudos
Reply
Prineel
Scout

Re: Scroll to a certain view

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)
 

367dbfa7-f5b6-403a-8698-cb3f13997bcc.png
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

0 Kudos
Reply
Prineel
Scout

Re: Scroll to a certain view

Hi @MdenHeijer,

 

Are your controls hidden?

 

Kind Regards

Prineel

0 Kudos
Reply
VJay
Scout

Re: Scroll to a certain view

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.

0 Kudos
Reply