今之人兮

今之人兮

我将孤身一人,高举火把,行于众人之前,探索黑暗,无所畏惧。

  • 财富值16365
  • 威望值10
  • 总积分16955

个人信息

  • 回复了 的回答

    给我瞅瞅你这块的代码是怎么设置的 gridview

    设置了,没用啊

  • 回复了 的回答

    参照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);
        }
    
     'rowOptions' => function ($model, $key,$index, $grid){
                  return ['data-key'=>$model['i_id']];
                },
    
  • 回复了 的回答

    参照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);
        }
    

    QQ图片20170417173924.png

  • 回复了 的回答

    参照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);
        }
    

    现在的问题是只有设置'data-key'的时候不行

  • 回复了 的回答

    给我瞅瞅你这块的代码是怎么设置的 gridview

    QQ图片20170417172304.png

  • 回复了 的回答

    QQ截图20170417165326.jpg

    不太清楚,我给你贴下图,再补充问题里面,你看下,难道是因为不是数字?

  • 回复了 的回答

    QQ截图20170417163141.jpg

    你按照上图的设置配置一下试试。

    问题改了下,顺便说明这样不行

  • 2017-04-16 已签到
    连续签到7天,获得了20个金钱
16955/20000
资料完整度
40/100
用户活跃度
0/100

Ta的关注

2

Ta的粉丝

8

Ta的访客

31