Does anyone know how to save the last vScroll position of a mobile scroller and display the vScroll bar position on the last position after the scroller is recreated?
I have a datagrid that will only show (for example) 10 records on the first time. When user clicks on the [Load More] button, the list will add up another 10 records below, which makes up 20 records, and so on.
Whenever more records are added into the datagrid, I will call the scroller_delete and scroller_create to recreate the scroller.
My problem is that even though the datagrid is able to display at the correct position, I can see that the vScroll bar will go back to the top of the datagrid contentRect (screencap: https://www.dropbox.com/s/k2xx8n6wzgw4y ... 0.png?dl=0). And when I tap on the mobile screen wanting to scroll down, the list will start from the top again!
Tried on scrolling list field, the result is the same. The scroller_create code is as follows:
Code: Select all
function scroller_create
local tScrollerRect, tContentRect
put the vScroll of fld "names" into tOldScroll
if environment() is not "mobile" then exit scroller_create
put the rect of grp "names" into tScrollerRect
put 0, 0,(the formattedWidth of fld "names"),(the formattedHeight of fld "names") into tContentRect
mobileControlCreate "scroller", "listScroll"
put the result into sScrollerID
mobileControlSet "listScroll", "rect", tScrollerRect
mobileControlSet "listScroll", "contentRect", tContentRect
mobileControlSet "listScroll", "visible", true
mobileControlSet "listScroll", "scrollingEnabled", true
mobileControlSet "listScroll", "vIndicator", true
mobileControlSet "listScroll", "vScroll", tOldScroll
end scroller_create

Thanks in advance!