Datagrid best practise
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Datagrid best practise
Pretty green to LC on iOs this far, I could use a hand.
I want a datagrid. I want to be able to scroll it with the finger and without a scrollbar.
What is the best practise here? Use a DG at all? Or create a custom scroller?
Any pointers much appreciated.
Malte
I want a datagrid. I want to be able to scroll it with the finger and without a scrollbar.
What is the best practise here? Use a DG at all? Or create a custom scroller?
Any pointers much appreciated.
Malte
Re: Datagrid best practise
I use a scroller, catch scrollerDidScroll messages in the card script like so:
HTH
cheers
Alan
Code: Select all
on scrollerDidScroll pOffsetX, pOffsetY
-- Set the scroll values of the group based on feedback from the scroller
set the dgVScroll of grp "yourDGName" to pOffsetY
end scrollerDidScroll
cheers
Alan
Re: Datagrid best practise
Thank you Alan,
do you happen to have an example stack?
Cheers,
Malte
do you happen to have an example stack?
Cheers,
Malte
Re: Datagrid best practise
Hi Malte
No good stack to share though I think I found one in these forums. My main scroller creation script is below. The main thing to remember is to use the dgFormattedHeight of grp "yourDataGridName" for finding out the height of the contents of the DG.
i.e.
put the dgFormattedHeight of grp "dgIndex" into tHeight
iphoneControlSet sScrollerId, "contentRect", (0, 0, the width of grp "dgIndex", tHeight)
At the moment it doesn't scroll that smoothly, but I expect that to change when I shift stuff to v. 5 and above and use the dynamic graphic settings - this helped for some other scrolling cases.
HTH... Good luck!
---
cheers
Alan
No good stack to share though I think I found one in these forums. My main scroller creation script is below. The main thing to remember is to use the dgFormattedHeight of grp "yourDataGridName" for finding out the height of the contents of the DG.
i.e.
put the dgFormattedHeight of grp "dgIndex" into tHeight
iphoneControlSet sScrollerId, "contentRect", (0, 0, the width of grp "dgIndex", tHeight)
At the moment it doesn't scroll that smoothly, but I expect that to change when I shift stuff to v. 5 and above and use the dynamic graphic settings - this helped for some other scrolling cases.
HTH... Good luck!
---
Code: Select all
on smCreateScroller
-- Create the scroller and store its id into local var
iphoneControlCreate "scroller"
put the result into sScrollerId
-- The 'rect' is the region of the card it should cover
iphoneControlSet sScrollerId, "rect", the rect of grp "dgIndex"
-- The 'contentRect' is the region the scroller scrolls over
-- for the datagrid, we need to use the "dgFormattedHeight" to get the content height
put the dgFormattedHeight of grp "dgIndex" into tHeight
iphoneControlSet sScrollerId, "contentRect", (0, 0, the width of grp "dgIndex", tHeight)
-- The 'visible' determines if the scroller is displayed
iphoneControlSet sScrollerId, "visible", "true"
-- The 'canBounce' determines whether the standard iOS 'bouncing' occurs at extremities of scrolling
iphoneControlSet sScrollerId, "canBounce", "true"
-- The 'pagingEnabled' determines whether scrolling only happens in multiples of the width/height
iphoneControlSet sScrollerId, "pagingEnabled", "false"
-- The 'canScrollToTop' determines whether touching the status bar scrolls the scroller to the top
iphoneControlSet sScrollerId, "canScrollToTop", "true"
end smCreateScroller
Alan
Re: Datagrid best practise
Ah, right... Thank you. Well. the problem if one sets the dg to its formattedheight, is that one looses out on all its main advantages. That is the caching and needing to draw only those parts that are visible! If you have very very long lists (100k + lines) I doubt this will be anywhere near performant enough...
Will have to be thinking about this more.
Thanks anyway.
Will have to be thinking about this more.

Thanks anyway.
Re: Datagrid best practise
Wait... did I read this completely wrong?
Can the dg be its actual visible height, but the scroller is not?
Thanks again,
Malte
Can the dg be its actual visible height, but the scroller is not?
Thanks again,
Malte
Re: Datagrid best practise
Hi Malte
No, you're setting the scroller to cover the rect of the DG, but you set the "contentRect" to the size of the content contained in the DG. Of course, this assumes that you've already populated the DG. If you do some clever stuff with populating it on the fly, then I guess you'll need to do something else. But this seems to work for me, though I only have about 1000 rows in the DG that I'm using, of which between 10 and 30 might be visible...
Does that make sense?
HTH
cheers
Alan
No, you're setting the scroller to cover the rect of the DG, but you set the "contentRect" to the size of the content contained in the DG. Of course, this assumes that you've already populated the DG. If you do some clever stuff with populating it on the fly, then I guess you'll need to do something else. But this seems to work for me, though I only have about 1000 rows in the DG that I'm using, of which between 10 and 30 might be visible...
Does that make sense?
HTH
cheers
Alan
Re: Datagrid best practise
Hi Alan,
a lot of sense.
The good thing about the datagrid is, it does not really matter if it is a thousand or 10 000 lines. I'll give this a try.
Thanks again,
Malte
a lot of sense.

The good thing about the datagrid is, it does not really matter if it is a thousand or 10 000 lines. I'll give this a try.
Thanks again,
Malte