Set the scroll in Datagrid

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Batninja
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 55
Joined: Sat Oct 15, 2011 9:43 am

Set the scroll in Datagrid

Post by Batninja » Wed Nov 30, 2016 10:16 pm

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

strongbow
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 146
Joined: Mon Jul 31, 2006 1:39 am
Contact:

Re: Set the scroll in Datagrid

Post by strongbow » Thu Dec 01, 2016 7:12 am

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!

Batninja
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 55
Joined: Sat Oct 15, 2011 9:43 am

Re: Set the scroll in Datagrid

Post by Batninja » Thu Dec 01, 2016 1:14 pm

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!

Post Reply