TableComponent

class TableComponent
addStaticColumn($colName, $options)

Add a static column to the table. This method is used only to specify information about the columns. To add data, you need to use TableComponent::addStaticRow to add rows of data.

The type of data in the column will be automatically detected but you can also override the type in the options.

Parameters:
  • $colName (string) – The name of the column
  • $options (TableColumnOptions) – Options for the column
addStaticRow($data)

Add a static row of data to the table. You need to add columns for each item in the array using TableComponent::addStaticColumn

The data must be an array of values of mixed types. The types will auto detected from the data but you can also override them while specifying the column.

Parameters:
  • $data (array) – An array of data to add
addColumn($name, $exp, $options)

Create a column from a Database Expression.

Parameters:
  • $name (string) – The name of the column
  • $exp (string) – A Database Expression
  • $options (TableColumnOptions) – The column options
fetchColumn()
addCustomHTMLColumn()
onRowClicked($callback, $target, $eventOptions)

An even that is fired when a Dashboard user clicks on a row.

Note that the event matters only on the row, and will be the same irrelavant of the column that is clicked.

The following paramters are sent to the callback:

  1. rowId - The index of the row that is clicked
  2. colId - the index of the column that is clicked on
  3. value - The value of the cell that was clicked
Parameters:
  • $callback (function) – The callback function to execute to handle the event
  • $target (RFComponent) – The target component. This should also be available on the same dashboard
  • $eventOptions (EventOptions|array) – The event options
onCellClicked($callback, $target, $eventOptions)

An even that is fired when a Dashboard user clicks on a cell.

The following paramters are sent to the callback:

  1. rowId - The index of the row that is clicked
  2. colId - the index of the column that is clicked on
  3. value - The value of the cell that was clicked
Parameters:
  • $callback (function) – The callback function to execute to handle the event
  • $target (RFComponent) – The target component. This should also be available on the same dashboard
  • $eventOptions (EventOptions|array) – The event options

Automatically filter another component based on a user’s interaction with the table.

Parameters:
  • $target (Component) – The target component
  • $options (array) –
getObjectType()
addSQLWhere($exp, $boolOperand)

Add a SQL WHERE clause to this component.

1. The contents of the expression are not Escaped or binded to prepared queries. Using this function in a non-secure manner may open up your dashboard to SQL Injection vulnerabilities. 2. This condition is only applied to this specific component, not to other components.

Parameters:
  • $exp (string) – The expression to add to the SQL Queries
  • $boolOperand (string) – The boolean operand for the condition. (“AND”/”OR)
sortOn($exp, $sortOrder)

Sort the data in the component based on a particular expression. This is equivalent to having an “ORDER BY” clause in your SQL Queries.

However, this function might not work as expected in components which have data aggregated and grouped by another column. If this is the case, you should use the in-built sorting functionality of the component itself.

1. The contents of the expression are not Escaped or binded to prepared queries. Using this function in a non-secure manner may open up your dashboard to SQL Injection vulnerabilities. 2. This condition is only applied to this specific component, not to other components.

Parameters:
  • $exp (string) – The expression to sort by
  • $sortOrder (string) – The Sort order (“ASC”/”DESC”)
limitTo($exp, $sortOrder)

Limit the data in the component based on a particular expression. This is equivalent to having an “LIMIT” clause in your SQL Queries.

Parameters:
  • $exp (int) – The number of records to take
  • $sortOrder (int) – The number of records to skip
addCondition($expression, $comparison, $value, $boolOperand)

Add a condition to the component. This is similar to having a “WHERE” clause in your SQL Query, but there are a few differences:

1. The $value parameter is protected against SQL Injection attacks so you do not need to worry about escaping the value. 2. There are specific comparisons that you can perform

The comparison operators you can use are:

  • Equality: “eq”, “==”, “isequalto”, “equals”, “equalto”, “equal”
  • Inequality: “neq”, ”!=”, “isnotequalto”, “notequals”, “notequalto”, “notequal”, “ne”
  • Less than: “lt”, “<”, “islessthan”, “lessthan”, “less”
  • Less than or equal to: “lte”, “<=”, “islessthanorequalto”, “lessthanequal”, “le”
  • Greater Than: “gt”, “>”, “isgreaterthan”, “greaterthan”, “greater”
  • Greater Than or Equal To: “gte”, “>=”, “isgreaterthanorequalto”, “greaterthanequal”, “ge”
  • Starts with: “startswith”
  • Ends wit: “endswith”
  • Contains: “contains”
Parameters:
  • $expression (string) – The column or expression to filter
  • $comparison (string) – The comparison operator
  • $value (mixed) – The value to compare against
  • $boolOperand (string) – The boolean operand (AND/OR)
addInitialCondition($expression, $comparison, $value, $boolOperand)

Add a condition which is only applied if there isn’t a drilldown.

Identical behavior to Component::addCondition

Parameters:
  • $expression (string) – The column or expression to filter
  • $comparison (string) – The comparison operator
  • $value (mixed) – The value to compare against
  • $boolOperand (string) – The boolean operand (AND/OR)
setDataSource($datasource)

Set the DataSource for this component.

The DataSource contains information on where to access the data to display in the component.

Parameters:
setCaching()

This function is Not Supported currently

addPostProcessRowCallback($callback)

After processing data (querying, fetching, filtering, etc), you can register a callback to be called with each row. Note that the callback can modify any row and return the final row.

Let’s say that you have a pie chart, but your database has values 0 and 1. You want to rewrite labels 0 => “Not Available” and 1 => “Available” you can add a callback like this

$pieChart->addPostProcessCallback('rewrite_labels');

function rewrite_labels ($row, $sourceComponent) { if($row[‘rfLabels’] === ‘0’) { $row[‘rfLabels’] = “Not Available”; } else if($row[‘rfLabels’] === ‘1’) { $row[‘rfLabels’] = “Available”; } return $row; // Don’t forget this }

Parameters:
  • $callback (function) – A function or name of function to execute
log($message)
Parameters:
  • $message (string) – The message to log
setOption()

Sets one or more options for this component.

You can call setOption in the following ways:

  1. With two params:

$component->setOption(‘caption’, “Hello!”);

  1. As an array of key-value pairs

$component->setOption (array( ‘caption’ => “Hello”, ‘numberPrefix’ => ‘$’ ));

3. As an object of the Options class for the component you’re using. for example, if you’re using it to configure a chart component, you can say

$opt = new ChartOptions();
$opt->caption = "hello";
$opt->numberPrefix = "$";
$component->setOption($opt);
setCaption($caption)

Set the caption for this component.

Parameters:
  • $caption (string) –
setPlaceholder(string)
Parameters:
  • string ($caption) – caption
setWidth($width)

Set the width class for this component.

The width can be 1 to 4.

See dimensions for more information on this

Parameters:
  • $width (int) – The width in Units of 1 to 4
setHeight($width)

Set the height class for this component.

See dimensions for more information on this

Parameters:
  • $width (int) – The height in Units
setDimensions($width, $height)

Set the dimensions for this component

The width can be between 1 to 4.

See dimensions for more information.

Parameters:
  • $width (int) – The width
  • $height (int) – The height
getID()
property ID

The ID of the object.

Every instance of the inherited cass created in a request will have a different ID

However, IDs are sequentially generated. So It’s certain that a script with multiple instances of a class

Type: string
Default: “(unset)”

Start building interactive, mobile-friendly Dashboards in PHP. See DemosDownload