Skip to content

Commit

Permalink
#350 - Fix attributes on td after update in classes `TbJsonButtonCo…
Browse files Browse the repository at this point in the history
…lumn` and `TbJsonCheckBoxColumn`
  • Loading branch information
Maksim Naumov committed Dec 17, 2013
1 parent d2e17ee commit f940b12
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 25 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Thank you all
Antonio Ramirez.

## YiiBooster latest development alpha
- **(fix)** Fix attributes on `td` after update in classes `TbJsonButtonColumn` and `TbJsonCheckBoxColumn` #350 (fromYukki)
- **(enh)** New attributes `readonly` and `disabled` for `TbSelect2` class #305 (fromYukki)
- **(fix)** Client validation for inline forms using `TbActiveForm` class #242 (fromYukki)
- **(enh)** Basic version of new widget jQuery UI Layout Manager (`TbUiLayout`) #390 (fromYukki)
Expand Down
39 changes: 31 additions & 8 deletions src/widgets/TbJsonButtonColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,42 @@ public function renderHeaderCell()
public function renderDataCell($row)
{
if ($this->grid->json) {
$data = $this->grid->dataProvider->data[$row];
$col = array();
ob_start();
$this->renderDataCellContent($row, $data);
$col['content'] = ob_get_contents();
ob_end_clean();
$col['attrs'] = '';
return $col;
$data = $this->grid->dataProvider->data[$row];
$options = $this->htmlOptions;
if ($this->cssClassExpression !== null) {
$class = $this->evaluateExpression($this->cssClassExpression, array('row' => $row, 'data' => $data));
if (!empty($class)) {
if (isset($options['class'])) {
$options['class'] .= ' ' . $class;
} else {
$options['class'] = $class;
}
}
}

return array(
'attrs' => CHtml::renderAttributes($options),
'content' => $this->renderDataCellContent($row, $data),
);
}

parent::renderDataCell($row);
}

protected function renderDataCellContent($row, $data)
{
ob_start();
parent::renderDataCellContent($row, $data);
$html = ob_get_contents();
ob_end_clean();

if ($this->grid->json) {
return $html;
}

echo $html;
}

/**
* Initializes the default buttons (view, update and delete).
*/
Expand Down
34 changes: 17 additions & 17 deletions src/widgets/TbJsonCheckBoxColumn.php
Original file line number Diff line number Diff line change
Expand Up @@ -77,24 +77,24 @@ protected function renderHeaderCellContent()
*/
public function renderDataCell($row)
{
$data = $this->grid->dataProvider->data[$row];
$options = $this->htmlOptions;
if ($this->cssClassExpression !== null) {
$class = $this->evaluateExpression($this->cssClassExpression, array('row' => $row, 'data' => $data));
if (!empty($class)) {
if (isset($options['class'])) {
$options['class'] .= ' ' . $class;
} else {
$options['class'] = $class;
}
}
}

if ($this->grid->json) {
return CMap::mergeArray(
$options,
array('content' => $this->renderDataCellContent($row, $data))
);
$data = $this->grid->dataProvider->data[$row];
$options = $this->htmlOptions;
if ($this->cssClassExpression !== null) {
$class = $this->evaluateExpression($this->cssClassExpression, array('row' => $row, 'data' => $data));
if (!empty($class)) {
if (isset($options['class'])) {
$options['class'] .= ' ' . $class;
} else {
$options['class'] = $class;
}
}
}

return array(
'attrs' => CHtml::renderAttributes($options),
'content' => $this->renderDataCellContent($row, $data),
);
}

parent::renderDataCell($row);
Expand Down

0 comments on commit f940b12

Please sign in to comment.