selectionChanged for datagrids
Posted: Fri Aug 07, 2009 9:14 pm
I found an example stack that uses this method to populate the datagrid...
put revDatabaseColumnNames(sCursorID) into sRecordFields
put revNumberOfRecords(sCursorID) into sRecordCount
set the dgNumberOfRecords of group "datagrid 1" to sRecordCount
command GetDataForLine pLine, @pOutData
revMoveToRecord sCursorID, pLine - 1
put ConvertCurrentRowToArray() into pOutData
end GetDataForLine
function ConvertCurrentRowToArray
local theArray
repeat for each item theField in sRecordFields
put revDatabaseColumnNamed(sCursorID,theField) into theArray[theField]
end repeat
return theArray
end ConvertCurrentRowToArray
selectionChanged code...
on selectionChanged pHilitedIndex, pPrevHilitedIndex
put the dgDataOfIndex [ pHilitedIndex ] of me into theDataA
end selectionChanged
Result...

If I use this method to populate the datagrid...
put revDatabaseColumnNames(sConnID, table) into theHeaders
put revDataFromQuery(,,sConnID,"SELECT * from table;") into theData
put 0 into x
repeat for each line dataLine in theData
add 1 to x
put 0 into y
repeat for each item headerTitle in theHeaders
add 1 to y
put item y of dataLine into arrayData[x][headerTitle]
end repeat
end repeat
set the dgData of group "datagrid 1" to arrayData
selectionChanged code...
on selectionChanged pHilitedIndex, pPrevHilitedIndex
put the dgDataOfIndex [ pHilitedIndex ] of me into theDataA
end selectionChanged
Result...

Both ways of populating the datagrid show the correct data but why does selectionChanged work for one but not the other?
put revDatabaseColumnNames(sCursorID) into sRecordFields
put revNumberOfRecords(sCursorID) into sRecordCount
set the dgNumberOfRecords of group "datagrid 1" to sRecordCount
command GetDataForLine pLine, @pOutData
revMoveToRecord sCursorID, pLine - 1
put ConvertCurrentRowToArray() into pOutData
end GetDataForLine
function ConvertCurrentRowToArray
local theArray
repeat for each item theField in sRecordFields
put revDatabaseColumnNamed(sCursorID,theField) into theArray[theField]
end repeat
return theArray
end ConvertCurrentRowToArray
selectionChanged code...
on selectionChanged pHilitedIndex, pPrevHilitedIndex
put the dgDataOfIndex [ pHilitedIndex ] of me into theDataA
end selectionChanged
Result...

If I use this method to populate the datagrid...
put revDatabaseColumnNames(sConnID, table) into theHeaders
put revDataFromQuery(,,sConnID,"SELECT * from table;") into theData
put 0 into x
repeat for each line dataLine in theData
add 1 to x
put 0 into y
repeat for each item headerTitle in theHeaders
add 1 to y
put item y of dataLine into arrayData[x][headerTitle]
end repeat
end repeat
set the dgData of group "datagrid 1" to arrayData
selectionChanged code...
on selectionChanged pHilitedIndex, pPrevHilitedIndex
put the dgDataOfIndex [ pHilitedIndex ] of me into theDataA
end selectionChanged
Result...

Both ways of populating the datagrid show the correct data but why does selectionChanged work for one but not the other?