DataGrid Question

7 messages Options
Embed this post
Permalink
charles61

DataGrid Question

Reply Threaded More More options
Print post
Permalink
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.    
ChrisWood

Re: DataGrid Question

Reply Threaded More More options
Print post
Permalink
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.

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.    
Trevor DeVore

Re: DataGrid Question

Reply Threaded More More options
Print post
Permalink
In reply to this post by charles61
On Oct 23, 2009, at 11:09 AM, 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.

Charles,

Here is a lesson I just added to the manual about AddData/AddLine.  
Take a look and see if this helps.

How Do I Add A Row Of Data To An Existing Data Grid?: <http://revolution.screenstepslive.com/spaces/revolution/manuals/datagrid/lessons/7094-How-Do-I-Add-A-Row-Of-Data-To-An-Existing-Data-Grid- 
 >

--
Trevor DeVore
Blue Mango Learning Systems
ScreenSteps: http://www.screensteps.com
Releasable Revolution Resources for Developers: http://revolution.bluemangolearning.com
_______________________________________________
use-revolution mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution
ChrisWood

Re: DataGrid Question

Reply Threaded More More options
Print post
Permalink
In reply to this post by charles61
Trevor,

That is excellent, its cut the code I was using inhalf (and I learnt about the dispatch command)!


<code>
   put "" into theNewRecord["First"]
   put "" into theNewRecord["Last"]
   put "" into theNewRecord["DOB"]
   put "" into theNewRecord["Age"]
   
   put 1 into theLineNo
   dispatch "AddData" to Group "dataGrid 1" with theNewRecord, theLineNo
   
--Select the first cell to start editing
   dispatch "EditCell" to Group "dataGrid 1" with  "First", theLineNo
   
<\code>

Regards

Chris
charles61

Re: DataGrid Question

Reply Threaded More More options
Print post
Permalink
Chris,

Thanks for your suggestion! I could not download the zipped file you uploaded to Nabble in your last e-mail. Could you e-mail it to me?


ChrisWood wrote:
Trevor,

That is excellent, its cut the code I was using inhalf (and I learnt about the dispatch command)!


<code>
   put "" into theNewRecord["First"]
   put "" into theNewRecord["Last"]
   put "" into theNewRecord["DOB"]
   put "" into theNewRecord["Age"]
   
   put 1 into theLineNo
   dispatch "AddData" to Group "dataGrid 1" with theNewRecord, theLineNo
   
--Select the first cell to start editing
   dispatch "EditCell" to Group "dataGrid 1" with  "First", theLineNo
   
<\code>

Regards

Chris
ChrisWood

Re: DataGrid Question

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Charles,

See attached file, hope it is useful.


Best Regards
Chris



On 8 Nov 2009, at 05:31, charles61 [via Runtime Revolution] wrote:

Chris,

Thanks for your suggestion! I could not download the zipped file you uploaded to Nabble in your last e-mail. Could you e-mail it to me?


ChrisWood wrote:
Trevor,

That is excellent, its cut the code I was using inhalf (and I learnt about the dispatch command)!


<code>
   put "" into theNewRecord["First"]
   put "" into theNewRecord["Last"]
   put "" into theNewRecord["DOB"]
   put "" into theNewRecord["Age"]
   
   put 1 into theLineNo
   dispatch "AddData" to Group "dataGrid 1" with theNewRecord, theLineNo
   
--Select the first cell to start editing
   dispatch "EditCell" to Group "dataGrid 1" with  "First", theLineNo
   
<\code>

Regards

Chris


Datagrid test.rev.zip (9K) Download Attachment
charles61

Re: DataGrid Question

Reply Threaded More More options
Print post
Permalink
Some javascript/style in this post has been disabled (why?)
Chris,

Your DataGrid stack you sent me was most helpful! I went back to the Rev's DataGrid video and followed the steps used to make a grid. I happy to say that I was successful! I did notice one thing that the code in the DataGrid video is slightly different when I processed to delete the Country field and replace it with a button. I have gotten a couple of errors as the result of the changes in the script. 

I am off from the work today and will have a chance to examine the script more closely. I am excited that the beta of Rev 4 will be available today. I like to use version 4 to build my project but because it is a beta I naturally have some reservations.

Thanks again for your example sample!


Charles Szasz





On Nov 7, 2009, at 8:50 PM, ChrisWood [via Runtime Revolution] wrote:

Charles,

See attached file, hope it is useful.


Best Regards
Chris



On 8 Nov 2009, at 05:31, charles61 [via Runtime Revolution] wrote:

Chris,

Thanks for your suggestion! I could not download the zipped file you uploaded to Nabble in your last e-mail. Could you e-mail it to me?


ChrisWood wrote:
Trevor,

That is excellent, its cut the code I was using inhalf (and I learnt about the dispatch command)!


<code>
   put "" into theNewRecord["First"]
   put "" into theNewRecord["Last"]
   put "" into theNewRecord["DOB"]
   put "" into theNewRecord["Age"]
   
   put 1 into theLineNo
   dispatch "AddData" to Group "dataGrid 1" with theNewRecord, theLineNo
   
--Select the first cell to start editing
   dispatch "EditCell" to Group "dataGrid 1" with  "First", theLineNo
   
<\code>

Regards

Chris


Datagrid test.rev.zip (9K) Download Attachment