Page 1 of 1

Set the scroll in Datagrid

Posted: Wed Nov 30, 2016 10:16 pm
by Batninja
Hi hoping for some help please.

I have a data grid working well on an iPhone build and the native scroller works great. But I want to have buttons to scroll to the bottom and top (not using the status bar).

I can scroll to the bottom using:

Code: Select all

set the dgVScroll of group "DataGrid 1" to the dgFormattedHeight of group "DataGrid 1"
or call the scrollerDidScroll with

Code: Select all

put the dgFormattedHeight of group "DataGrid 1" into scrollend
      scrollerDidScroll 0, scrollend
i.e. calling in the card script

Code: Select all

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the dgVScroll of group "DataGrid 1" to vOffset --Datagrid 1 is the name of the datagrid group
end scrollerDidScroll
But the scroll won't "stick". As soon as I touch the Datagrid it goes back to the original scroll location!

How can I scroll to a location using the native scroller and have it use that as the location to scroll from?

Thanks for any and all suggestions or comments.

Roger

Re: Set the scroll in Datagrid

Posted: Thu Dec 01, 2016 7:12 am
by strongbow
You also need to set the scroll of the native scroller.

e.g.

Code: Select all

mobileControlSet "yourNativeScrollerName", "vScroll", the dgFormattedHeight of group "DataGrid 1"
HTH!

Re: Set the scroll in Datagrid

Posted: Thu Dec 01, 2016 1:14 pm
by Batninja
Doh!

Brilliant! thank you so much.

I had to change to code slightly to account for the height of the data grid group displayed otherwise the end scrolled a screen too far.

Code: Select all

   if environment() is "mobile" then mobileControlSet "myscroll", "vScroll", the dgFormattedHeight of group "DataGrid 1" - the height of group "DataGrid 1" 
Thanks again!