LiveCode LessonsLiveCode Data Grid Data Grid FundamentalsHow Do I Customize A Table's Columns?

How Do I Customize A Table's Columns?

A column template is nothing more than a Revolution control that is named after a column in your table. This control is located in the row template group for your data grid. This lesson will discuss how to create templates for columns in a data grid table.

Use Property Inspector To Create a Column Template

Use Property Inspector To Create a Column Template

In the Property Inspector, select the column you would like to customize (1). Click the "+" button at the bottom of the pane to create a column template (2).

Edit the Row Template Group

Edit the Row Template Group

In order to customize the look we need to edit the contents of the template group. Select it (1) and click "Edit Group" (2) in the Revolution toolbar.

Edit Column Group

Edit Column Group

Now select the column group (1) and click "Edit Group" again (2). At this point you can customize what controls appear in the column template.

A Column Template

A Column Template

In this example I have created three controls for three different columns in my data grid table.

1) A field named "Time" that formats data into a time format (I just renamed the field that was included in the row template by default).

2) A group named "My Rating". The group has some buttons that display the image of a star.

3) A button named "Genre" that offers different Genre selections.

Here is what those controls look like in the Application Browser. Notice how all of the controls are located in the "Row Template" group.

Supporting Controls

Supporting Controls

The controls I created ("Time" field, "Genre" button and "My Rating" group) each have behaviors associated with them. I've stored the buttons containing these behaviors, as well as the "star.png" image on the same card as the "Row Template" group.

Behavior Example

Behavior Example

Here is what the FillInData handler looks like for the "My Rating" column. pData (1) contains the value of the "My Rating" column for the row being displayed. Note how this parameter differs than the parameter sent to FillInData for a row template. For a row template the parameter passed in is an array.

We then use that value to determine how many stars to display (2).

Result

Result

Here is what the table looks like now that I've defined some custom column templates. The table found controls named "Genre", "Time" and "My Rating" in the record template group so those were used to render the data for those three columns.

2 Comments

Michael

In a Table, can I customize a cell to re-format itself to increase its height and display text that is wrapped in the cell so that none of the text is cut off?

Trevor DeVore

@Michael: Not at this time. Tables have a fixed line height so you can only adjust the height for all rows, not individual rows.

Add your comment

E-Mail me when someone replies to this comment