DataGrid Native Scrollers
Posted: Mon May 12, 2025 2:20 am
I'm posting this here because it took me a while to figure all this out from a number of different sources. And inevitably, I will need this information in the future but have forgotten it. So I am doing my future self a favor by putting it into the forum in one place so when I search for "datagrid native scroller", it's all right here!
Datagrids on mobile have built in native scrollers. They get created automatically when you go to a card with a datagrid on it, and they are destroyed automatically when you leave the card. Very helpful. Unfortunately, they also have a few annoyances. For instance, if you disable a datagrid, then the datagrid dutifully stops accepting any touch input - it stops scrolling and you can't click on anything. You can, however, still swipe down and the vertical indicator will dutifully move down as if the datagrid was scrolling. And, in fact, the datagrid is scrolling; the dgvscroll of the datagrid is changing, but the display is not updating so you don't see it. But as soon as you enable the datagrid and touch it, it will "jump" to where ever you scrolled. Needless-to-say this is not the desired behavior and can be very disconcerting. And unfortunately there is no "dgProp[]" property which will remove this behavior.
Fortunately, datagrid scrollers are "normal" mobile scrollers created with "mobileControlCreate" and therefore you can use the regular "mobileControlSet" routines on them. You just need to know the mobile scroller's name, which is always the "long ID" of the datagrid. So I have the following code in the group script of my datagrids:
So now when I went to TRULY disable a datagrid, instead of running I run
And the datagrid is truly disabled. It doesn't accept any touch input, there's no vertical indicator, and the dgvscoll does not change when you swipe it. Then obviously I re-enable it with
And again, using "mobileControlSet", you can change anything on your datagrid's scroller that can be changed for a native scroller. So now my datagrids act on mobile like I want them to act!

Datagrids on mobile have built in native scrollers. They get created automatically when you go to a card with a datagrid on it, and they are destroyed automatically when you leave the card. Very helpful. Unfortunately, they also have a few annoyances. For instance, if you disable a datagrid, then the datagrid dutifully stops accepting any touch input - it stops scrolling and you can't click on anything. You can, however, still swipe down and the vertical indicator will dutifully move down as if the datagrid was scrolling. And, in fact, the datagrid is scrolling; the dgvscroll of the datagrid is changing, but the display is not updating so you don't see it. But as soon as you enable the datagrid and touch it, it will "jump" to where ever you scrolled. Needless-to-say this is not the desired behavior and can be very disconcerting. And unfortunately there is no "dgProp[]" property which will remove this behavior.
Fortunately, datagrid scrollers are "normal" mobile scrollers created with "mobileControlCreate" and therefore you can use the regular "mobileControlSet" routines on them. You just need to know the mobile scroller's name, which is always the "long ID" of the datagrid. So I have the following code in the group script of my datagrids:
Code: Select all
on disableMe
disable me
if the environment is "mobile" then
local tLongID
put the long ID of me into tLongID
mobileControlSet tLongID, "scrollingEnabled", false
mobileControlSet tLongID, "vIndicator", false
end if
end disableMe
on enableMe
enable me
if the environment is "mobile" then
local tLongID
put the long ID of me into tLongID
mobileControlSet tLongID, "scrollingEnabled", true
mobileControlSet tLongID, "vIndicator", true
end if
end enableMe
Code: Select all
disable grp "datagridName"
Code: Select all
send "disableMe" to grp "datagridName"
Code: Select all
send "enableMe" to grp "datagridName"