Creating A Data Grid By Hand

This lesson will show you how to create a data grid through script.

Copy Data Grid From revDataGridLibrary

The data grid template is stored in the revDataGridLibrary stack and can be copied using some code similar to this:

copy group "DataGrid" of group "Templates" of stack "revDataGridLibrary" to card "MyCard" of stack "MyStack"

put it into theDataGridRef

Set The "style" Property

set the dgProp["style"] of theDataGridRef to "table" or "form"

Assign a Row Template

set the dgProp["row template"] of theDataGridRef to the long id of group "MyRowTemplate" of stack "MyStack"

You should probably create this ahead of time using the IDE. For example, you could create a data grid and then delete it while leaving the row template behind (it will exist on a card in "Data Grid Templates xxx" stack).

2 Comments

Kevin Tildsley

"The data grid template is stored in the revDataGridLibrary stack and can be copied using some code similar to this:"

where is the revDataGridLibrary stack please ?
First line of your example fails as it cannot find such a stack.
Is it a stack I have to download, or is it a resource somewhere that comes with livecode installtion ?

Bjoernke von Gierke

The revDataGridLibrary is part of the IDE. You can see it by enabling "LiveCode UI elements appear in lists" on the General tab of the IDE Preferences, then opening the "Application Browser" from the Tools menu.

When you try out the code, make sure you use a LC version that contains the Datagrid (Rev 3.0 and up). Also make sure to change the last part of the code line to point to a valid stack. Unless you have created a card "MyCard" in a stack called "MyStack", that is.

See also these lessons:
http://runrev.screenstepslive.com/s/lessons/m/datagrid/l/7339-What-Do-I-Need-to-Do-To-Deploy-a-Standalone-With-A-Data-Grid-
http://runrev.screenstepslive.com/s/lessons/m/datagrid/l/36470-How-do-I-create-a-Datagrid-dynamically-from-tab-delimited-data

Add your comment

E-Mail me when someone replies to this comment