Page 1 of 1
datagrid scroller android
Posted: Mon Dec 15, 2014 2:13 pm
by vedus
i am using bellow code from klaus have posted for datagrid.
in the ios device and simulator working perfect.
On Android is static..?
Code: Select all
local sScrollerID
## Create scroller now:
on opencard
create_scroller
end opencard
on closecard
delete_scroller
end closecard
command create_scroller
put "DataGrid 1" into tScrollerGroup
if the environment <> "mobile" then
exit create_scroller
end if
## Create native scroller object and save its ID in a local variable
MobileControlCreate "scroller"
put the result into sScrollerId
## RECT is the area on the card where the SCOLLER should do its work
MobileControlSet sScrollerId, "rect", (the rect of grp tScrollerGroup)
put the width of grp tScrollerGroup into tWidth
put the dgFormattedheight of grp tScrollerGroup into tHeight
set the dgvScroll of grp tScrollerGroup to 0
## WHAT part fo the datagrid shall be scrolled-> the complete datagrid
MobileControlSet sScrollerId, "contentRect", (0,0,tWidth,tHeight)
## Display SCROLLER
MobileControlSet sScrollerId, "visible", "true"
## the typical BUMP effect when you ge to the edge of the object
MobileControlSet sScrollerId, "canBounce", "true"
MobileControlSet sScrollerId, "pagingEnabled", "false"
MobileControlSet sScrollerId, "vIndicator", "false"
MobileControlSet sScrollerId, "borderStyle", "none"
MobileControlSet sScrollerId, "canScrollToTop", "false"
end create_scroller
## Will be sent when the user actually SCROLLs with his finger
on scrollerDidScroll OffsetX, OffsetY
lock screen
set the dgvScroll of grp "DataGrid 1" to OffsetY
unlock screen
end scrollerDidScroll
## REMOVE natove object when card closes!!!!!
command delete_scroller
if the environment <> "mobile" then
exit delete_scroller
end if
MobileControlDelete sScrollerId
end delete_scroller
and this code is on datagrid group
Code: Select all
on selectionChanged pHilitedIndex, pPrevHilitedIndex
# hilited index and get the uID of that control.
put the dgDataControlOfIndex[pHilitedIndex] of me into theSelectedControl
if theSelectedControl is not empty then
put the uID of theSelectedControl into theSelectedID
uiViewRecord theSelectedID
end if
lock screen for visual effect
go to cd card4
unlock screen with visual effect scroll left very fast
end selectionChanged
if i remove the code from datagrid the scroller working,is this bug for android scroll?
Re: datagrid scroller android
Posted: Wed Dec 17, 2014 7:39 pm
by vedus
no One have similar problem with selectionChanged pHilitedIndex ?
Re: datagrid scroller android
Posted: Tue Jan 20, 2015 7:31 pm
by vedus
can anyone give me a clue or help with above problem?
I am looking on this more than 3 weeks but still i can make the scroller to work.
The datagrid is in the Form format no table.
Re: datagrid scroller android
Posted: Sun Jan 25, 2015 5:14 pm
by keram
Hi vedus,
Sorry for coming in so late but I just noticed your post today.
I've been using the same DG scroller from Klaus. It works on Android but I don't have any other code in DG group.
I'm not clear what the code that you remove temporarily from the DG is supposed to do, but would it be possible to place it somewhere else?
You can also test if the DG scroller in
Data Grid Helper works. Download trial from this website:
http://www.aslugontheroad.com/ourproducts
The code will be placed in the DG but for Android you'll have to change all the "iPhone" commands for the "mobile" commands - they are not synonymous.
keram
Re: datagrid scroller android
Posted: Sun Jan 25, 2015 11:45 pm
by vedus
hi Keram thank you for the help.
i have the data grid helper plugin and i have test it.Working well in the ios but no results on android phone.
i will make more clear what i use and what is the problem bellow
i am using a database file (sqlite) with more than (10 columns and about 10.000 rows) and because my app hang(maybe because of many records i have use the bellow code
The datagrid is on the form setup with 2 fields (title & subtitle)
on the card i use this code to get the data.
Code: Select all
global tTitles
Global myArray
Global myID
global sConnID
local sCursorID, sRowCursorID
local sRecordFields
local sRecordCount
on preopenCard
resetgrid
uiPopulateListGroup
## Initialize the UI
pass preopencard
end preopenCard
command uiPopulateListGroup
CloseCursor
OpenMoviesCursor
## Cache number of records so we can display useful info
## to the user
put revNumberOfRecords(sCursorID) into sRecordCount
## Track time it takes
put the seconds into theStart
lock screen
## Setting the dgNumberOfRecords of a data grid turns on dynamic
## record fetching. Rather than storing the data that is being displayed
## in an internal array the data grid fires off the GetDataForLine message
## in which you return the data for the appropriate line.
set the dgNumberOfRecords of group "DataGrid1" of card "card3" to sRecordCount
unlock screen
end uiPopulateListGroup
## this message is sent to the Data Grid but we handle it here
## so that you can see all handlers in one spot
command GetDataForLine pLine, @pOutData
## Revolution 3.5 added revMoveToRecord to revDB. This makes it really
## easy to navigate to the proper record for pLine
revMoveToRecord sCursorID, pLine - 1 -- 0 based record navigation
put revDatabaseColumnNumbered(sCursorId, 1) into theRowID
put revQueryDatabase(sConnID,"select id,title,content from datadrinks where rowid = " & theRowID ) into sRowCursorID
if sRowCursorID is an integer then
## Now convert record in the row cursor to an array for the data grid
put ConvertCurrentRowToArray() into pOutData
revCloseCursor sRowCursorID
end if
end GetDataForLine
function ConvertCurrentRowToArray
local theArray
if sRecordFields is empty then
## Cache the fields in the cursor in a script local variable.
put revDatabaseColumnNames(sRowCursorID) into sRecordFields
end if
## Converts current record in the cursor into a single dimensional array.
## Note we are using the cached script local sRecordFields
repeat for each item theField in sRecordFields
put revDatabaseColumnNamed(sRowCursorID, theField) into theArray[theField]
end repeat
return theArray
end ConvertCurrentRowToArray
command OpenMoviesCursor
switch tTitles
case "cocktails"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'cock%' ") into sCursorID
//set the backgroundpattern of graphic id 1078 of group id "1012" of card id 1011 of stack "Data Grid Templates 1417794119370" to 1052
break
case "Liqueurs"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'liq%' ") into sCursorID
break
case "noalco"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'Non%' ") into sCursorID
break
case "Punches"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'Punc%' ") into sCursorID
break
case "otherdrinks"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'other%' ") into sCursorID
break
case "shots"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'shot%' ") into sCursorID
break
case "beer"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'beer%' ") into sCursorID
break
case "coffee"
put revQueryDatabase(sConnID,"SELECT rowid FROM datadrinks where cat like 'coffee%' ") into sCursorID
//set the backgroundpattern of graphic id 1078 of group id "1012" of card id 1011 of stack "Data Grid Templates 1417794119370" to 1053
break
end switch
if sCursorID is not an integer then
answer "Error opening cursor:" && sCursorID & "."
exit to top
end if
end OpenMoviesCursor
command CloseCursor
try
revCloseCursor sCursorID
catch e
end try
end CloseCursor
----------=========------------------
command uiViewRecord pID
put "SELECT * from datadrinks WHERE ID = " & pID into theSQL
put pID into fld "pidfld" of cd "card4"
end uiViewRecord
--=============
on resetgrid
send "ResetControl" to group "DataGrid1"
put empty into sRecordFields
--put revDataFromQuery(tab, cr, sConnID, theSQL) into theData
end resetgrid
on closeCard
put empty into sRecordFields
## Close the database connection as we don't need it any longer
//CloseDatabase
end closeCard
on the datagrid i use this code to get the hilite
Code: Select all
on selectionChanged pHilitedIndex, pPrevHilitedIndex
## Note: Because the data grid is feeding data from the database to
## the datagrid we can't use handlers like dgDataOfIndex.
## Instead the FillInData handler in the data grid row behavior
## stores the database id and makes it accessible in the uID custom property.
## To get the id to pass to uiViewRecord we get the control associated with the
## hilited index and get the uID of that control.
put the dgDataControlOfIndex[pHilitedIndex] of me into theSelectedControl
if theSelectedControl is not empty then
put the uID of theSelectedControl into theSelectedID
uiViewRecord theSelectedID
end if
lock screen for visual effect
go to cd card4
unlock screen with visual effect scroll left very fast
end selectionChanged
and in the row behavior i am useing the bellow
Code: Select all
local sID
on FillInData pDataArray
## Note: Because the data grid is feeding data from the database to
## the datagrid we can't use handlers like dgDataOfIndex.
## Store id in script local variable that gets returned in uID script local
## the uID can be used in a selectionChanged handler for example
put pDataArray["id"] into sID
set the text of field "label1" of me to pDataArray["title"]
set the text of field "label2" of me to pDataArray["content"]
TruncateTail the short id of fld "label2" of me, "..."
end FillInData
#on layoutControl
# -- todo: Resize your control based on content
# put the rect of me into theOriginalRect
# put the rect of fld "label1" of me into theRect
# put item 3 of theOriginalRect into item 3 of theRect
# set the rect of graphic "label1" of me to theRect
#end layoutControl
setprop dgHilite pBoolean
end dgHilite
getprop dgDataControl
return the long id of me
end dgDataControl
getprop uID
## Returns the database id for the record displayed in this control.
## See FillInData
return sID
end uID
if i remove the
on selectionChanged pHilitedIndex, pPrevHilitedIndex from the datagrid the scrollers(anyone i have test is working on the android).
if i enable the code again the scroller stop working.
Re: datagrid scroller android
Posted: Mon Jan 26, 2015 2:06 am
by newtronsols
you may find it works on pre- version 7 e.g. 6.7. Which one I don't know.
I found my Android scroller didn't work using v7. But maybe it works in 7.0.2 (rc1) - I haven't checked yet.
Re: datagrid scroller android
Posted: Mon Jan 26, 2015 2:21 am
by keram
Hi vedus,
You have lots of code on the card (on propenCard) together with the scroller code. Is there a way to relocate the code from that card that is not related to scroller to some other place? Or create myCardCode command (its script in the stack) and put it in the card with scroller code? Wild idea? maybe, but worth trying.
Re: datagrid scroller android
Posted: Mon Jan 26, 2015 6:23 pm
by vedus
keram wrote:Hi vedus,
You have lots of code on the card (on propenCard) together with the scroller code. Is there a way to relocate the code from that card that is not related to scroller to some other place? Or create myCardCode command (its script in the stack) and put it in the card with scroller code? Wild idea? maybe, but worth trying.
i have split the code with opencard and preopencard and i have put the dgh scroller in the datagrid,still i get the same.no move on the scroller.
Is like the
on selectionChanged pHilitedIndex, pPrevHilitedIndex override the scroller..
maybe is a bug?
Re: datagrid scroller android
Posted: Mon Jan 26, 2015 7:49 pm
by keram
If you suspect that it may be a bug in DGH scroller then post a question here:
http://forums.livecode.com/viewforum.php?f=78