The LinkColumn Class

The LinkColumn is a versatile column class that offers a variety of ways to create a column that has a link or button in it. Such links are typically used for navigation, but can be used to popup dialogs or take other actions.

To create a link column, call createLinkColumn() like so:

$objTable->createLinkColumn($strColumnName, $mixText, $mixDestination, $getVars, $tagAttributes, $blnAsButton);

A description of each parameter follows:

  • $strColumnName: The name you would like to give the column and that appears in the column header.
  • $mixText: The text that will be visible to the user, typically underlined for standard links, or inside a button. This can be a static string, or the value can be extracted from the DataSource item as by specifying one of the following:
    • A callable callback function e.g. [$this, 'labelRender']
    • If the data source contains objects, a property in the object e.g. '->Project'
    • If the data source contains arrays, a string with a key value of the array, surrounded by brackets e.g. '[id]'
    • If the data source contains arrays, an array of keys to look for e.g. ['person']['name']
  • $mixDestination: If given, the destination or action to take when the link is clicked. As above, you can pass a static string, or extract this value using a callback, a property, or a key in an array. The returned value should be the name of a file to go to or a URL. You can also pass a Proxy and it will be used as the destination.
  • $getVars: If given, one of the following:
    • If $mixDestination was a Proxy, this will become the action parameter of the proxy. You can use any of the above methods to extract this value from the data source.
    • If $mixDestination is a string that represents a file or URL, you should pass in a key/value array. Each key will become a get variable attached to the $mixDestination URL, and each value will be used as above to extract a value from the data source.
  • $tagAttributes: If given, a key/value array that becomes attributes for the anchor or button tag. This could be used to specify an class, id, or data- attribute. As above, it can be extracted from the data itself.
  • $blnAsButton: If drawing a Proxy, you can set this to true to draw it as a button.

As you can see, quite elaborate links can be created using this column.

In the example, the first column has a link column that you click on, and the second column a link that you hover over. The first column goes to the same page you are viewing, but adds a GET variable to the URL, detects it, and puts a message at the bottom of the table depending on what line you clicked on. The second column use a Proxy to detect when your mouse hovers over a link, and puts up a similar message.

You clicked on ACME Payment System