johnny1991
- johnny1991 提出了问题安装doc api出问题了
view 有这个widget方法吗?
- johnny1991 2017-04-18 已签到连续签到4天,获得了20个金钱
- johnny1991 回复了 Cathay 的评论
除了composer安装,直接下载的怎么配置?
下载好了之后,放在vendor文件下面,然后配置一下yiisoft下面的exetension.php里面的配置就可以的,难点在于按照yii框架的类自动加载机制配置好别名
- johnny1991 收藏了扩展markdown编辑器
- johnny1991 回复了 johnny1991 的回答
参照yii\grid\GridView的这两个方法
public function renderTableBody() { $models = array_values($this->dataProvider->getModels()); $keys = $this->dataProvider->getKeys(); $rows = []; foreach ($models as $index => $model) { $key = $keys[$index]; if ($this->beforeRow !== null) { $row = call_user_func($this->beforeRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } $rows[] = $this->renderTableRow($model, $key, $index); if ($this->afterRow !== null) { $row = call_user_func($this->afterRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } } if (empty($rows)) { $colspan = count($this->columns); return "<tbody>\n<tr><td colspan=\"$colspan\">" . $this->renderEmpty() . "</td></tr>\n</tbody>"; } else { return "<tbody>\n" . implode("\n", $rows) . "\n</tbody>"; } } 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); }
@Edwin 看源码啊
- johnny1991 回复了 johnny1991 的回答
参照yii\grid\GridView的这两个方法
public function renderTableBody() { $models = array_values($this->dataProvider->getModels()); $keys = $this->dataProvider->getKeys(); $rows = []; foreach ($models as $index => $model) { $key = $keys[$index]; if ($this->beforeRow !== null) { $row = call_user_func($this->beforeRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } $rows[] = $this->renderTableRow($model, $key, $index); if ($this->afterRow !== null) { $row = call_user_func($this->afterRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } } if (empty($rows)) { $colspan = count($this->columns); return "<tbody>\n<tr><td colspan=\"$colspan\">" . $this->renderEmpty() . "</td></tr>\n</tbody>"; } else { return "<tbody>\n" . implode("\n", $rows) . "\n</tbody>"; } } 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); }
@Edwin 具体通过这个来设置的
$keys = $this->dataProvider->getKeys(); - johnny1991 回复了 johnny1991 的回答
参照yii\grid\GridView的这两个方法
public function renderTableBody() { $models = array_values($this->dataProvider->getModels()); $keys = $this->dataProvider->getKeys(); $rows = []; foreach ($models as $index => $model) { $key = $keys[$index]; if ($this->beforeRow !== null) { $row = call_user_func($this->beforeRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } $rows[] = $this->renderTableRow($model, $key, $index); if ($this->afterRow !== null) { $row = call_user_func($this->afterRow, $model, $key, $index, $this); if (!empty($row)) { $rows[] = $row; } } } if (empty($rows)) { $colspan = count($this->columns); return "<tbody>\n<tr><td colspan=\"$colspan\">" . $this->renderEmpty() . "</td></tr>\n</tbody>"; } else { return "<tbody>\n" . implode("\n", $rows) . "\n</tbody>"; } } 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); }
@Edwin ‘data-key’从源码看起来,是单独设置的,
$options['data-key'] = is_array($key) ? json_encode($key) : (string) $key;