Page 1 of 1

Android Native Scroller for a Data Grid

Posted: Sat Apr 05, 2014 3:32 am
by keram
Hello,

I would like to replace the standard scroller of the data grid in a standalone for Android with the native scrolling (by swipping).

On the card level I have this code:

Code: Select all

on openCard
      local tScrollerRect, tContentRect
   
   // Only create a scroller on a mobile device
   if environment() is not "mobile" then exit openCard
   
   // Set the area of the scroller
   put the rect of group "DataGrid 1" into tScrollerRect
   
   // Set the area of the content to be scrolled
  put 0,0,(the formattedWidth of group "DataGrid 1"),(the formattedHeight of group "DataGrid 1") into tContentRect
   
   // Create the scroller control
   mobileControlCreate "scroller", "loremScroll"
   put the result into sScrollerID
   
   // Set the properties of the scroller
   mobileControlSet "loremScroll", "rect", tScrollerRect
   mobileControlSet "loremScroll", "contentRect", tContentRect
   mobileControlSet "loremScroll", "visible", true
   mobileControlSet "loremScroll", "scrollingEnabled", true
   mobileControlSet "loremScroll", "vIndicator", true
   mobileControlSet "loremScroll", "vscroll", 0
   
end openCard

on closeCard
   // Delete the scroller
   if environment() is not "mobile" then exit closeCard
   mobileControlDelete sScrollerID
end closeCard

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   set the vScroll of group "DataGrid 1" to vOffset
end scrollerDidScroll
I tried the same code for a group of objects and it works, but with data grid it does not.
The stack is attached.
Any ideas how to correct the code? Thanks.

keram

Re: Android Native Scroller Data Grid

Posted: Sat Apr 05, 2014 3:35 am
by Simon
Check out Hanson's answer in the comments here:
http://lessons.runrev.com/s/lessons/m/4 ... ll-a-field
Asked by Kevin

Simon

Re: Android Native Scroller for a Data Grid

Posted: Sat Apr 05, 2014 4:57 pm
by keram
Thanks Simon for the tip.

Hanson's suggestion was:
"...make the datagrid as big as you need it to be so you can fit all of the data on one page, that way removing its own scrollers. The result could then be added to a group that is controlled by the native mobile scrollers."

I did that (see the attached stack) and it still does not work.
Besides this when making the dg so big as to fit 640 text lines without the scroller the height of it is about 16000! Then it takes loooong time to start up such an app. I guess it's because all the lines are being loaded at once, while with the scroller just the visible lines are loaded. (The attached stacks has only 15 lines).

There must be something that must be done more directly with the data grid. I wish Zryip TheSlug would be around...

keram

Re: Android Native Scroller for a Data Grid

Posted: Sat Apr 05, 2014 6:55 pm
by Klaus
Hi keram,

a datagrid is not an ordinary group, so you need to take that into account :D

Change this:

Code: Select all

...
 // Set the area of the content to be scrolled
  ## put 0,0,(the formattedWidth of group "DataGrid 1"),(the formattedHeight of group "DataGrid 1") into tContentRect
  put 0,0,(the DGformattedWidth of group "DataGrid 1"),(the DGformattedHeight of group "DataGrid 1") into tContentRect
...
And this:

Code: Select all

on scrollerDidScroll hOffset, vOffset
   // When the user scrolls move the displayed content
   ##  set the vScroll of group "DataGrid 1" to vOffset
   set the DGvScroll of group "DataGrid 1" to vOffset
end scrollerDidScroll
Best

Klaus

Re: Android Native Scroller for a Data Grid

Posted: Tue Apr 08, 2014 2:00 am
by keram
Hi Klaus,

Thanks for your corrections!
I delayed to answer because I was testing it in different ways.
The scrolling works OK when "All Lines" are selected but when only 1of the categories are selected or "My selection" view then the scrolling does not work.
I'm not sure if it's a glitch in the scrolling code or the code for saving the data - see my other post: "how to save data on mobile (android)".
Once I get that sorted out I'll give you another feedback.

keram

Re: Android Native Scroller for a Data Grid

Posted: Tue Apr 08, 2014 12:03 pm
by keram
Hi Klaus,

Basically your fix is working OK - thanks! :)
There is some glitch with scrolling - see my other post here:
http://ftp.runrev.com/forums/viewtopic. ... ed#p100941
but I don't know what it depends on.

keram