lib/components/web/widgets/grid/View.php
public function setColumns($columns)
    {
        $this->_columns = [];
        foreach ($columns as $key => $columnName) {
            if (is_array($columnName)) {
                $settings = $columnName;
                $settings['name'] = $key;
            } else {
                $settings = ['name' => $columnName];
            }
            if (!isset($settings['class'])) {
                $settings['class'] = '\cascade\web\widgets\grid\columns\Data';
            }
            if (!isset($settings['value'])) {
                $settings['type'] = 'raw';
                $settings['value'] = function ($data, $row) use ($settings) {
                    $key = explode('.', $settings['name']);
                    $object = $data;
                    while (count($key) > 1) {
                        $next = array_shift($key);
                        if (is_object($object)) {
                            $object = $object->{$next};
                        } else {
                            $object = $object[$next];
                        }
                    }
                    $key = $key[0];
                    if (is_object($object)) {
                        $model = get_class($object);
                        $fields = $model::getFields($object);
                        if (isset($fields[$key])) {
                            return $fields[$key]->getFormattedValue();
                        }
                    }

                    return $object->{$key};
                };
            }
            if (!isset($settings['type'])) {
                $settings['type'] = 'raw';
            }
            $column = Yii::createObject($settings, $this);
            $key = $column->name;

            if (!$column->visible) {
                //	continue;
            }
            $this->_columns[$key] = $column;
        }
    }
public function setColumns($columns)
    {
        $this->_columns = [];
        foreach ($columns as $key => $columnName) {
            if (is_array($columnName)) {
                $settings = $columnName;
                $settings['name'] = $key;
            } else {
                $settings = ['name' => $columnName];
            }
            if (!isset($settings['class'])) {
                $settings['class'] = '\cascade\web\widgets\grid\columns\Data';
            }
            if (!isset($settings['value'])) {
                $settings['type'] = 'raw';
                $settings['value'] = function ($data, $row) use ($settings) {
                    $key = explode('.', $settings['name']);
                    $object = $data;
                    while (count($key) > 1) {
                        $next = array_shift($key);
                        if (is_object($object)) {
                            $object = $object->{$next};
                        } else {
                            $object = $object[$next];
                        }
                    }
                    $key = $key[0];
                    if (is_object($object)) {
                        $model = get_class($object);
                        $fields = $model::getFields($object);
                        if (isset($fields[$key])) {
                            return $fields[$key]->getFormattedValue();
                        }
                    }

                    return $object->{$key};
                };
            }
            if (!isset($settings['type'])) {
                $settings['type'] = 'raw';
            }
            $column = Yii::createObject($settings, $this);
            $key = $column->name;

            if (!$column->visible) {
                //	continue;
            }
            $this->_columns[$key] = $column;
        }
    }
public function setColumns ( $ columns ) { $ this -> _columns = [ ] ; foreach ( $ columns as $ key => $ columnName ) { if ( is_array ( $ columnName ) ) { $ settings = $ columnName ; $ settings [ 'name' ] = $ key ; } else { $ settings = [ 'name' => $ columnName ] ; } if ( ! isset ( $ settings [ 'class' ] ) ) { $ settings [ 'class' ] = '\cascade\web\widgets\grid\columns\Data' ; } if ( ! isset ( $ settings [ 'value' ] ) ) { $ settings [ 'type' ] = 'raw' ; $ settings [ 'value' ] = function ( $ data , $ row ) use ( $ settings ) { $ key = explode ( '.' , $ settings [ 'name' ] ) ; $ object = $ data ; while ( count ( $ key ) > 1 ) { $ next = array_shift ( $ key ) ; if ( is_object ( $ object ) ) { $ object = $ object -> { $ next } ; } else { $ object = $ object [ $ next ] ; } } $ key = $ key [ 0 ] ; if ( is_object ( $ object ) ) { $ model = get_class ( $ object ) ; $ fields = $ model :: getFields ( $ object ) ; if ( isset ( $ fields [ $ key ] ) ) { return $ fields [ $ key ] -> getFormattedValue ( ) ; } } return $ object -> { $ key } ; } ; } if ( ! isset ( $ settings [ 'type' ] ) ) { $ settings [ 'type' ] = 'raw' ; } $ column = Yii :: createObject ( $ settings , $ this ) ; $ key = $ column -> name ; if ( ! $ column -> visible ) { //	continue; } $ this -> _columns [ $ key ] = $ column ; } }
Set columns.

@param [[@doctodo param_type:columns]] $columns [[@doctodo param_description:columns]]

@return [[@doctodo return_type:setColumns]] [[@doctodo return_description:setColumns]]
Set columns .