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.