yii\grid\GridView::renderTableRow PHP Method

renderTableRow() public method

Renders a table row with the given data model and key.
public renderTableRow ( mixed $model, mixed $key, integer $index ) : string
$model mixed the data model to be rendered
$key mixed the key associated with the data model
$index integer the zero-based index of the data model among the model array returned by [[dataProvider]].
return string the rendering result
    public function renderTableRow($model, $key, $index)
    {
        $cells = [];
        /* @var $column Column */
        foreach ($this->columns as $column) {
            $cells[] = $column->renderDataCell($model, $key, $index);
        }
        if ($this->rowOptions instanceof Closure) {
            $options = call_user_func($this->rowOptions, $model, $key, $index, $this);
        } else {
            $options = $this->rowOptions;
        }
        $options['data-key'] = is_array($key) ? json_encode($key) : (string) $key;
        return Html::tag('tr', implode('', $cells), $options);
    }

Usage Example

Example #1
0
 public function renderTableRow($model, $key, $index)
 {
     if ($this->filterRow !== null && call_user_func($this->filterRow, $model, $key, $index, $this) === false) {
         return '';
     }
     return parent::renderTableRow($model, $key, $index);
 }