The problem i have is with datagrid form.I have 2 fields (lbl1 and lbl2) to show the data i want( is from 2 columns)
The data is about 9500 records and when i try it the LC 7.0.1 rc2 is hang. So i try the dgNumberOfRecords and GetDataForLine from the lesson example http://lessons.runrev.com/s/lessons/m/d ... ts-of-data
still LC hang when i try to show the datagrid.
IF i change the dgNumberOfRecords to 100 i have the data in the datagrid but some cells is empty(i have include the photo from datagrid)

If remove the limit from dgNumberOfRecords and put
Code: Select all
set the dgNumberOfRecords of group "DataGrid1" to sRecordCount
any help from experts for this problem ?
Code: Select all
global tTitle
Global mydbid
local sCursorID, sRowCursorID
local sRecordFields
local sRecordCount
on preopenCard
send "ResetControl" to group "DataGrid1"
uiPopulateListGroup
## Initialize the UI
pass preopencard
end preopenCard
on closeCard
put empty into sRecordFields
## Close the database connection as we don't need it any longer
CloseDatabase
end closeCard
command uiPopulateListGroup
## Connect to database and get records
CloseCursor
OpenDatabase
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" to 50//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
## The rowID is stored in the cursor. Open another cursor that contains all fields for this record.
--put revQueryDatabase(mydbid,"SELECT * FROM datadrinks WHERE rowid = " & theRowID) into sRowCursorID
put revQueryDatabase(mydbid,"select title,content from datadrinks where centralcat like 'Cocktails' and 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 OpenDatabase
set the wholematches to true
if mydbid is not an integer OR mydbid is not among the items of revOpenDatabases() then
put the filename of this stack into thePath
set the itemdelimiter to slash
put "drinksfull.sqlite" into the last item of thePath
put revOpenDatabase("sqlite",thePath,,,,) into mydbid
if mydbid is not an integer then
answer "Error connecting to the database:" && mydbid & "."
put empty into mydbid
exit to top
end if
end if
end OpenDatabase
command CloseDatabase
try
revCloseDatabase mydbid
catch e
end try
end CloseDatabase
command OpenMoviesCursor
## Selecting 50,000 records can take a bit of time. The method used in this
## example selects the rowid of the 50,000 records and stores that in a cursor.
## In GetDataForLine the rowid is used to fetch the entire record. This is much faster.
put revQueryDatabase(mydbid,"SELECT rowid FROM datadrinks") into sCursorID
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 revDataFromQuery(tab, cr, mydbid, theSQL) into theData
end uiViewRecord