LiveCode LessonsData Grid Tips & Tricks TablesHow Do I Add Tooltips To Column Headers?

How Do I Add Tooltips To Column Headers?

Currently column headers in a data grid table do not have a tooltip property. You can still get tooltips to appear, however, by customizing the default behavior script for column headers. This lesson will show you how.

Open Template Card For Data Grid Table

Open Template Card For Data Grid Table

Open the template card for the data grid table by clicking on the Row Template button in the property inspector.

Create Button For Custom Behavior

Create Button For Custom Behavior

Drag a button onto the template card and name it My Header Behavior.

Assign Script

Assign Script

Assign the script of the My Header Behavior button to the script of button "Default Header" of stack "revDataGridLibrary". This ensures that your behavior has the same basic behavior that a column header should have.

Customize Script

Customize Script

Now edit the script of the My Header Behavior button. You want to customize the dgLabel setProp.

Add a new line to the setProp that assigns the tooltip of field 1 of me. In this example I'm calling a function that takes the name of the column (pValue) as the first parameter. I'm going to define the function in the data grid group script.

Define Function That Returns Tooltip

Define Function That Returns Tooltip

Select your data grid and edit it's script. Define the SomeFunctionThatReturnsToolTip function to return a tooltip based on the column name passed in.

function SomeFunctionThatReturnsToolTip pColumn
   switch pColumn
      case "col 1"
         return "A tooltip for column 1"
         break
      case "col 2"
         return "A tooltip for column 2"
         break             
   end switch
end SomeFunctionThatReturnsToolTip

Assign "default header behavior" Property

Assign "default header behavior" Property

To finish up you just need to assign the "default header behavior" property to the long id of the My Header Behavior button. This tells the data grid to use the script of your button rather than the default script supplied with the data grid.

Refresh Data Grid

Refresh Data Grid

Click the Refresh Data Grid button in the property inspector to refresh all of the controls.

Test

Test

Now when you roll over a column header the tooltip will appear.

0 Comments

Add your comment

E-Mail me when someone replies to this comment