How Do I Display Line Numbers in a Table?
This lesson will show you how to dynamically display line numbers in your data grid table.
Add Line Number Column
Reorder and Create Column Template
Edit Line Number Group
Edit Column Behavior
Edit Behavior Script
There isn't much to do here. In FillInData you just want to 'set the text of field 1 of me to the dgLine of me' (1). The dgLine is a property of a row template and this will display the line number for the current line. In LayoutControl you just need to set the rect of the field so that it fills the entire cell (2).
But How Do I Set the dgText Then?
You may be wondering how you would set the dgText property of this data grid since we have added a "Line Number" column as the first column in the table.
When you set the dgText of a data grid you can pass a parameter specifying whether or not the first line of text contains the names of the columns that the data should map to. Just pass in true and prepend the column names to your data like this:
put "Name,Artist,Composer,Album" into theColNames
set the dgText [true] of group "Data Grid" to theColNames & cr & theData