Overview

Packages

  • application
    • commands
    • components
      • actions
      • filters
      • leftWidget
      • permissions
      • sortableWidget
      • util
      • webupdater
      • x2flow
        • actions
        • triggers
      • X2GridView
      • X2Settings
    • controllers
    • models
      • embedded
    • modules
      • accounts
        • controllers
        • models
      • actions
        • controllers
        • models
      • calendar
        • controllers
        • models
      • charts
        • models
      • contacts
        • controllers
        • models
      • docs
        • components
        • controllers
        • models
      • groups
        • controllers
        • models
      • marketing
        • components
        • controllers
        • models
      • media
        • controllers
        • models
      • mobile
        • components
      • opportunities
        • controllers
        • models
      • products
        • controllers
        • models
      • quotes
        • controllers
        • models
      • services
        • controllers
        • models
      • template
        • models
      • users
        • controllers
        • models
      • workflow
        • controllers
        • models
      • x2Leads
        • controllers
        • models
  • Net
  • None
  • PHP
  • system
    • base
    • caching
      • dependencies
    • collections
    • console
    • db
      • ar
      • schema
        • cubrid
        • mssql
        • mysql
        • oci
        • pgsql
        • sqlite
    • i18n
      • gettext
    • logging
    • test
    • utils
    • validators
    • web
      • actions
      • auth
      • filters
      • form
      • helpers
      • renderers
      • services
      • widgets
        • captcha
        • pagers
  • Text
    • Highlighter
  • zii
    • behaviors
    • widgets
      • grid
      • jui

Classes

  • CButtonColumn
  • CCheckBoxColumn
  • CDataColumn
  • CGridColumn
  • CGridView
  • CLinkColumn
  • X2CheckBoxColumn
  • X2DataColumnGeneric
  • Overview
  • Package
  • Class
  • Tree

Class CButtonColumn

CButtonColumn represents a grid view column that renders one or several buttons.

By default, it will display three buttons, "view", "update" and "delete", which triggers the corresponding actions on the model of the row.

By configuring CButtonColumn::$buttons and CButtonColumn::$template properties, the column can display other buttons and customize the display order of the buttons.

CComponent
Extended by CGridColumn
Extended by CButtonColumn

Direct known subclasses

EButtonColumnWithClearFilters, X2ButtonColumn
Package: zii\widgets\grid
Copyright: 2008-2013 Yii Software LLC
License: http://www.yiiframework.com/license/
Author: Qiang Xue <qiang.xue@gmail.com>
Since: 1.1
Located at x2engine/framework/zii/widgets/grid/CButtonColumn.php
Methods summary
public
# init( )

Initializes the column. This method registers necessary client script for the button column.

Initializes the column. This method registers necessary client script for the button column.

Overrides

CGridColumn::init()
protected
# initDefaultButtons( )

Initializes the default buttons (view, update and delete).

Initializes the default buttons (view, update and delete).

protected
# registerClientScript( )

Registers the client scripts for the button column.

Registers the client scripts for the button column.

public string
# getDataCellContent( integer $row )

Returns the data cell content. This method renders the view, update and delete buttons in the data cell.

Returns the data cell content. This method renders the view, update and delete buttons in the data cell.

Parameters

$row
integer
$row the row number (zero-based)

Returns

string
the data cell content.

Since

1.1.16

Overrides

CGridColumn::getDataCellContent()
protected
# renderButton( string $id, array $button, integer $row, mixed $data )

Renders a link button.

Renders a link button.

Parameters

$id
string
$id the ID of the button
$button
array
$button the button configuration which may contain 'label', 'url', 'imageUrl' and 'options' elements. See CButtonColumn::$buttons for more details.
$row
integer
$row the row number (zero-based)
$data
mixed
$data the data object associated with the row
Methods inherited from CGridColumn
__construct(), getFilterCellContent(), getFooterCellContent(), getHasFooter(), getHeaderCellContent(), renderDataCell(), renderFilterCell(), renderFooterCell(), renderHeaderCell()
Methods inherited from CComponent
__call(), __get(), __isset(), __set(), __unset(), asa(), attachBehavior(), attachBehaviors(), attachEventHandler(), canGetProperty(), canSetProperty(), detachBehavior(), detachBehaviors(), detachEventHandler(), disableBehavior(), disableBehaviors(), enableBehavior(), enableBehaviors(), evaluateExpression(), getEventHandlers(), hasEvent(), hasEventHandler(), hasProperty(), raiseEvent()
Properties summary
public array $htmlOptions array('class'=>'button-column')
#

the HTML options for the data cell tags.

the HTML options for the data cell tags.

public array $headerHtmlOptions array('class'=>'button-column')
#

the HTML options for the header cell tag.

the HTML options for the header cell tag.

public array $footerHtmlOptions array('class'=>'button-column')
#

the HTML options for the footer cell tag.

the HTML options for the footer cell tag.

public string $template '{view} {update} {delete}'
#

the template that is used to render the content in each data cell. These default tokens are recognized: {view}, {update} and {delete}. If the CButtonColumn::$buttons property defines additional buttons, their IDs are also recognized here. For example, if a button named 'preview' is declared in CButtonColumn::$buttons, we can use the token '{preview}' here to specify where to display the button.

the template that is used to render the content in each data cell. These default tokens are recognized: {view}, {update} and {delete}. If the CButtonColumn::$buttons property defines additional buttons, their IDs are also recognized here. For example, if a button named 'preview' is declared in CButtonColumn::$buttons, we can use the token '{preview}' here to specify where to display the button.

public string $viewButtonLabel
#

the label for the view button. Defaults to "View". Note that the label will not be HTML-encoded when rendering.

the label for the view button. Defaults to "View". Note that the label will not be HTML-encoded when rendering.

public string $viewButtonImageUrl
#

the image URL for the view button. If not set, an integrated image will be used. You may set this property to be false to render a text link instead.

the image URL for the view button. If not set, an integrated image will be used. You may set this property to be false to render a text link instead.

public string $viewButtonUrl 'Yii::app()->controller->createUrl("view",array("id"=>$data->primaryKey))'
#
a PHP expression that is evaluated for every view button and whose result is used as the URL for the view button. In this expression, you can use the following variables:
  • <span class="php-var">$row</span> the row number (zero-based)
  • <span class="php-var">$data</span> the data model for the row
  • <span class="php-var">$this</span> the column object
The PHP expression will be evaluated using CComponent::evaluateExpression().

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

a PHP expression that is evaluated for every view button and whose result is used as the URL for the view button. In this expression, you can use the following variables:
  • <span class="php-var">$row</span> the row number (zero-based)
  • <span class="php-var">$data</span> the data model for the row
  • <span class="php-var">$this</span> the column object
The PHP expression will be evaluated using CComponent::evaluateExpression().

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

public array $viewButtonOptions array('class'=>'view')
#

the HTML options for the view button tag.

the HTML options for the view button tag.

public string $updateButtonLabel
#

the label for the update button. Defaults to "Update". Note that the label will not be HTML-encoded when rendering.

the label for the update button. Defaults to "Update". Note that the label will not be HTML-encoded when rendering.

public string $updateButtonImageUrl
#

the image URL for the update button. If not set, an integrated image will be used. You may set this property to be false to render a text link instead.

the image URL for the update button. If not set, an integrated image will be used. You may set this property to be false to render a text link instead.

public string $updateButtonUrl 'Yii::app()->controller->createUrl("update",array("id"=>$data->primaryKey))'
#
a PHP expression that is evaluated for every update button and whose result is used as the URL for the update button. In this expression, you can use the following variables:
  • <span class="php-var">$row</span> the row number (zero-based)
  • <span class="php-var">$data</span> the data model for the row
  • <span class="php-var">$this</span> the column object
The PHP expression will be evaluated using CComponent::evaluateExpression().

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

a PHP expression that is evaluated for every update button and whose result is used as the URL for the update button. In this expression, you can use the following variables:
  • <span class="php-var">$row</span> the row number (zero-based)
  • <span class="php-var">$data</span> the data model for the row
  • <span class="php-var">$this</span> the column object
The PHP expression will be evaluated using CComponent::evaluateExpression().

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

public array $updateButtonOptions array('class'=>'update')
#

the HTML options for the update button tag.

the HTML options for the update button tag.

public string $deleteButtonLabel
#

the label for the delete button. Defaults to "Delete". Note that the label will not be HTML-encoded when rendering.

the label for the delete button. Defaults to "Delete". Note that the label will not be HTML-encoded when rendering.

public string $deleteButtonImageUrl
#

the image URL for the delete button. If not set, an integrated image will be used. You may set this property to be false to render a text link instead.

the image URL for the delete button. If not set, an integrated image will be used. You may set this property to be false to render a text link instead.

public string $deleteButtonUrl 'Yii::app()->controller->createUrl("delete",array("id"=>$data->primaryKey))'
#
a PHP expression that is evaluated for every delete button and whose result is used as the URL for the delete button. In this expression, you can use the following variables:
  • <span class="php-var">$row</span> the row number (zero-based)
  • <span class="php-var">$data</span> the data model for the row
  • <span class="php-var">$this</span> the column object
The PHP expression will be evaluated using CComponent::evaluateExpression().

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

a PHP expression that is evaluated for every delete button and whose result is used as the URL for the delete button. In this expression, you can use the following variables:
  • <span class="php-var">$row</span> the row number (zero-based)
  • <span class="php-var">$data</span> the data model for the row
  • <span class="php-var">$this</span> the column object
The PHP expression will be evaluated using CComponent::evaluateExpression().

A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

public array $deleteButtonOptions array('class'=>'delete')
#

the HTML options for the delete button tag.

the HTML options for the delete button tag.

public string $deleteConfirmation
#

the confirmation message to be displayed when delete button is clicked. By setting this property to be false, no confirmation message will be displayed. This property is used only if <span class="php-var">$this</span>->buttons[<span class="php-quote">'delete'</span>][<span class="php-quote">'click'</span>] is not set.

the confirmation message to be displayed when delete button is clicked. By setting this property to be false, no confirmation message will be displayed. This property is used only if <span class="php-var">$this</span>->buttons[<span class="php-quote">'delete'</span>][<span class="php-quote">'click'</span>] is not set.

public string $afterDelete
#

a javascript function that will be invoked after the delete ajax call. This property is used only if <span class="php-var">$this</span>->buttons[<span class="php-quote">'delete'</span>][<span class="php-quote">'click'</span>] is not set.

The function signature is <span class="php-keyword1">function</span>(<span class="php-keyword2">link</span>, success, data)
  • <span class="php-keyword2">link</span> references the delete link.
  • success status of the ajax call, true if the ajax call was successful, false if the ajax call failed.
  • data the data returned by the server in case of a successful call or XHR object in case of error.
Note that if success is true it does not mean that the delete was successful, it only means that the ajax call was successful.

Example:

 array(
    class'=>'CButtonColumn',
    'afterDelete'=>'function(link,success,data){ if(success) alert("Delete completed successfully"); }',
 ),

a javascript function that will be invoked after the delete ajax call. This property is used only if <span class="php-var">$this</span>->buttons[<span class="php-quote">'delete'</span>][<span class="php-quote">'click'</span>] is not set.

The function signature is <span class="php-keyword1">function</span>(<span class="php-keyword2">link</span>, success, data)
  • <span class="php-keyword2">link</span> references the delete link.
  • success status of the ajax call, true if the ajax call was successful, false if the ajax call failed.
  • data the data returned by the server in case of a successful call or XHR object in case of error.
Note that if success is true it does not mean that the delete was successful, it only means that the ajax call was successful.

Example:

 array(
    class'=>'CButtonColumn',
    'afterDelete'=>'function(link,success,data){ if(success) alert("Delete completed successfully"); }',
 ),
public array $buttons array()
#

the configuration for buttons. Each array element specifies a single button which has the following format:

'buttonID' => array(
    'label'=>'...',     // text label of the button
    'url'=>'...',       // a PHP expression for generating the URL of the button
    'imageUrl'=>'...',  // image URL of the button. If not set or false, a text link is used
    'options'=>array(...), // HTML options for the button tag
    'click'=>'...',     // a JS function to be invoked when the button is clicked
    'visible'=>'...',   // a PHP expression for determining whether the button is visible
)

In the PHP expression for the 'url' option and/or 'visible' option, the variable <span class="php-var">$row</span> refers to the current row number (zero-based), and <span class="php-var">$data</span> refers to the data model for the row. The PHP expression will be evaluated using CComponent::evaluateExpression(). A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

If the 'buttonID' is 'view', 'update' or 'delete' the options will be applied to the default buttons.

Note that in order to display non-default buttons, the CButtonColumn::$template property needs to be configured so that the corresponding button IDs appear as tokens in the template.

the configuration for buttons. Each array element specifies a single button which has the following format:

'buttonID' => array(
    'label'=>'...',     // text label of the button
    'url'=>'...',       // a PHP expression for generating the URL of the button
    'imageUrl'=>'...',  // image URL of the button. If not set or false, a text link is used
    'options'=>array(...), // HTML options for the button tag
    'click'=>'...',     // a JS function to be invoked when the button is clicked
    'visible'=>'...',   // a PHP expression for determining whether the button is visible
)

In the PHP expression for the 'url' option and/or 'visible' option, the variable <span class="php-var">$row</span> refers to the current row number (zero-based), and <span class="php-var">$data</span> refers to the data model for the row. The PHP expression will be evaluated using CComponent::evaluateExpression(). A PHP expression can be any PHP code that has a value. To learn more about what an expression is, please refer to the php manual.

If the 'buttonID' is 'view', 'update' or 'delete' the options will be applied to the default buttons.

Note that in order to display non-default buttons, the CButtonColumn::$template property needs to be configured so that the corresponding button IDs appear as tokens in the template.

Properties inherited from CGridColumn
$cssClassExpression, $filterHtmlOptions, $footer, $grid, $header, $id, $visible
Magic properties inherited from CGridColumn
$filterCellContent, $footerCellContent, $hasFooter, $headerCellContent
API documentation generated by ApiGen 2.8.0