DataGrid Question
Chris Wood
chris_wood at gmx.com
Mon Oct 26 21:45:51 EDT 2009
Charles,
Perhaps this is not the best way to do it but it works. In this example
there is an existing table style DataGrid with 4 columns named First, Last
DOB & Age.
<code>
--Get existing number of lines
put the dgNumberOfLines of group "DataGrid 1" into theLineNo
put theLineNo + 1 into theLineNo
--Create empty array to act as new record
put "" into theNewRecord[theLineNo]["First"]
put "" into theNewRecord[theLineNo]["Last"]
put "" into theNewRecord[theLineNo]["DOB"]
put "" into theNewRecord[theLineNo]["Age"]
--load existing DataGrid into array
put the dgdata of group "DataGrid 1" into theDataGridData
--Merge the 2 arrays
union theNewRecord with theDataGridData
--Load the merged data into the datagrid
set the dgdata of group "DataGrid 1" to theNewRecord
--Get the current sort order
--This will allow us to discover if the new record will appear in the
first or last row
put the dgProp["sort by column"] of group "DataGrid 1" into
curSortedColumn
put the dgColumnSortDirection[curSortedColumn] of group "DataGrid 1" into
curSortOrder
if curSortOrder = "ascending" then
put 1 into theLineNo
end if
--Select the first cell for editing
put "First" into theColumn
send "EditCell theColumn, theLineNo" to group "dataGrid 1"
</code>
This hasn't been tested much and then only in a table style grid on OS X
10.5, so if anybody can suggest how to improve this code or more
efficientway to do this then I'd be grateful to hear from you.
http://www.nabble.com/file/p26054785/Datagrid%2Btest.rev.zip
Datagrid+test.rev.zip
Best Regards
Chris
Charles Szasz wrote:
>
> Using the RevList and Rev tutorials I have gone through examples of a
> DataGrid being used to display information from a file. I have not seen
> any examples of where the user enters the information in an app to get it
> displayed in a DataGrid. If anyone has any simple examples of using
> DataGrid in this manner, I would really appreciate it you would share it
> with me.
>
--
View this message in context: http://www.nabble.com/DataGrid-Question-tp26028143p26054785.html
Sent from the Revolution - User mailing list archive at Nabble.com.
More information about the use-livecode
mailing list