Configure the visible columns
437774
public function buildFields()
    {
        if ($this->domainConfiguration->isMultiDomainHost()) {
            $this->addField('domain', 'redirect.adminlist.header.domain', true);
        }
        $this->addField('origin', 'redirect.adminlist.header.origin', true);
        $this->addField('target', 'redirect.adminlist.header.target', true);
        $this->addField('permanent', 'redirect.adminlist.header.permanent', true);
        $this->addField('note', 'redirect.adminlist.header.note', true);
    }
967380
def setColumns( self, columns ):
        
        self.setColumnCount(len(columns))
        self.setHorizontalHeaderLabels(columns)
201939
def adjust_cells(self):
        """"""
        self.resizeColumnsToContents()
        fm = self.horizontalHeader().fontMetrics()
        names = [fm.width(s.cmd) for s in self.source_model.servers]
        if names:
            self.setColumnWidth(CMD, max(names))
        self.horizontalHeader().setStretchLastSection(True)
691414
private function hasColumnConfiguration($column)
    {
        $columns = $this->options[self::GRID_PARAM_COLUMNS];

        foreach ($columns as $configuration) {
            // By default a column is considered as visible
            if (!isset($configuration[self::GRID_PARAM_HIDDEN])) {
                $configuration[self::GRID_PARAM_HIDDEN] = false;
            }

            // Find linearly (must exists and must not be hidden)
            if ($column == $configuration[self::GRID_PARAM_COLUMN] && $configuration[self::GRID_PARAM_HIDDEN] != true) {
                return true;
            }
        }

        // Not found by default
        return false;
    }
488596
public void setColumnVisible(String colName, boolean visible) {
        ColumnDefEx col = findColumn(colName);
        if (col == null) return;
        col.setVisible(visible);
        JsDataTable.setColVisible(getElement(), colName, visible);
    }
735024
public function getVisibleColumns()
    {
        $columns = array();
        foreach ($this->columns as $column) {
            if ($column->visible) {
                $columns[] = $column;
            }
        }

        return $columns;
    }
808965
public function visibleColumns()
    {
        $visible = array_filter(explode(',', request(Tools\ColumnSelector::SELECT_COLUMN_NAME)));

        if (empty($visible)) {
            return $this->columns;
        }

        array_push($visible, '__row_selector__', '__actions__');

        return $this->columns->filter(function (Column $column) use ($visible) {
            return in_array($column->getName(), $visible);
        });
    }
641673
def toggleColumnByAction( self, action ):
        
        if ( action.text() == 'Show All' ):
            self.blockSignals(True)
            self.setUpdatesEnabled(False)
            for col in range(self.columnCount()):
                self.setColumnHidden(col, False)
            self.setUpdatesEnabled(True)
            self.blockSignals(False)
            
            self.setColumnHidden(0, False)
            
        elif ( action.text() == 'Hide All' ):
            self.blockSignals(True)
            self.setUpdatesEnabled(False)
            for col in range(self.columnCount()):
                self.setColumnHidden(col, True)
                
            # ensure we have at least 1 column visible
            self.blockSignals(False)
            self.setUpdatesEnabled(True)
            
            self.setColumnHidden(0, False)
            
        else:
            col     = self.column(action.text())
            state   = not action.isChecked()
            self.setColumnHidden(col, state)
            if ( state ):
                self.resizeColumnToContents(col)
            
            # ensure we at least have 1 column visible
            found = False
            for col in range(self.columnCount()):
                if ( not self.isColumnHidden(col) ):
                    found = True
                    break
            
            if not found:
                self.setColumnHidden(0, False)
        
        self.resizeToContents()
        self.update()
363858
def _swap_columns(self, side):
        """"""
        displayed_cols = self._displayed_cols
        i1 = self._dragged_col_index
        i2 = i1 + 1 if side == 'right' else i1 - 1
        if 0 <= i2 < len(displayed_cols):
            # there is a neighbor, swap columns:
            displayed_cols[i1] = displayed_cols[i2]
            displayed_cols[i2] = self._dragged_col
            self["displaycolumns"] = displayed_cols
            if side == 'left':
                right = self._dragged_col_neighbor_widths[0]
                self._dragged_col_x -= right  # update dragged column x coordinate
                # set new left neighbor width
                if i2 > 0:
                    left = ttk.Treeview.column(self, displayed_cols[i2 - 1], 'width')
                else:
                    left = None
            else:
                left = self._dragged_col_neighbor_widths[1]
                self._dragged_col_x += left  # update x coordinate of dragged column
                # set new right neighbor width
                if i2 < len(displayed_cols) - 1:
                    right = ttk.Treeview.column(self, displayed_cols[i2 + 1], 'width')
                else:
                    right = None
            self._dragged_col_index = i2  # update dragged column index
            self._dragged_col_neighbor_widths = (left, right)
1093791
def adjust_cells(self):
        """"""
        self.resizeColumnsToContents()
        fm = self.horizontalHeader().fontMetrics()
        names = [fm.width(s.name + ' '*9) for s in self.source_model.shortcuts]
        self.setColumnWidth(NAME, max(names))
        self.horizontalHeader().setStretchLastSection(True)
1068960
function (container) {
        container.items().filter(':visible').each(function (ctrl) {
          var settings = ctrl.settings;

          ctrl.layoutRect({
            x: settings.x,
            y: settings.y,
            w: settings.w,
            h: settings.h
          });

          if (ctrl.recalc) {
            ctrl.recalc();
          }
        });
      }
549165
def _configure_sti
      column = model.inheritance_column
      if sti_create_links
        columns[column].form_ui ||= :hidden
      else
        columns[column].form_ui ||= :select
        columns[column].options ||= {}
        columns[column].options[:options] = sti_children.collect do |model_name|
          [model_name.to_s.camelize.constantize.model_name.human, model_name.to_s.camelize]
        end
      end
    end
650824
function setColumnVisibleByIndex(index, visible) {
    if (index >= 0) {
        var column = this.gridCompColumnArr[index],
            visibleIndex = this.getVisibleIndexOfColumn(column),
            canVisible = column.options.canVisible,
            l = $('input:checked', $('#' + this.options.id + '_column_menu_columns_ul')).length;
        if (!canVisible && visible == false) {
            return;
        }
        // 显示处理
        if (column.options.visible == false && visible) {
            var htmlStr = '<col';
            if (column.options.width) {
                htmlStr += ' style="width:' + this.formatWidth(column.options.width) + '"';
            }
            htmlStr += '>';
            // 当前列之后的显示列的index
            var nextVisibleIndex = this.getNextVisibleInidexOfColumn(column);
            $('#' + this.options.id + '_header_table th:eq(' + index + ')').css('display', "");
            $('#' + this.options.id + '_content_table th:eq(' + index + ')').css('display', "");
            $('td:eq(' + index + ')', $('#' + this.options.id + '_content tbody tr')).css('display', "");
            if (nextVisibleIndex < 0) {
                this.lastVisibleColumn = column;
                // 添加在最后面
                try {
                    $('#' + this.options.id + '_header_table col:last')[0].insertAdjacentHTML('afterEnd', htmlStr);
                    $('#' + this.options.id + '_content_table col:last')[0].insertAdjacentHTML('afterEnd', htmlStr);
                } catch (e) {
                    $('#' + this.options.id + '_header_table col:last').after(htmlStr);
                    $('#' + this.options.id + '_content_table col:last').after(htmlStr);
                }
            } else {
                // 添加在下一个显示列之前
                try {
                    $('#' + this.options.id + '_header_table col:eq(' + (nextVisibleIndex - 1) + ')')[0].insertAdjacentHTML('beforeBegin', htmlStr);
                    $('#' + this.options.id + '_content_table col:eq(' + (nextVisibleIndex - 1) + ')')[0].insertAdjacentHTML('beforeBegin', htmlStr);
                } catch (e) {
                    $('#' + this.options.id + '_header_table col:eq(' + (nextVisibleIndex - 1) + ')').before(htmlStr);
                    $('#' + this.options.id + '_content_table col:eq(' + (nextVisibleIndex - 1) + ')').before(htmlStr);
                }
            }
            var newContentW = this.contentWidth + parseInt(column.options.width);
            if (this.showType == 'grid') {
                $('#' + this.options.id + '_column_menu_columns_ul li input:eq(' + index + ')')[0].checked = true;
            }
        }
        // 隐藏处理
        if (column.options.visible == true && !visible) {
            $('#' + this.options.id + '_header_table th:eq(' + index + ')').css('display', "none");
            $('#' + this.options.id + '_header_table col:eq(' + visibleIndex + ')').remove();
            $('#' + this.options.id + '_content_table th:eq(' + index + ')').css('display', "none");
            $('#' + this.options.id + '_content_table col:eq(' + visibleIndex + ')').remove();
            $('td:eq(' + index + ')', $('#' + this.options.id + '_content_table tbody tr')).css('display', "none");
            // 隐藏之后需要判断总体宽度是否小于内容区最小宽度，如果小于需要将最后一列进行扩展
            var newContentW = this.contentWidth - parseInt(column.options.width);
            if (this.showType == 'grid') {
                $('#' + this.options.id + '_column_menu_columns_ul li input:eq(' + index + ')')[0].checked = false;
            }
            if (this.lastVisibleColumn == column) {
                var allVisibleColumns = this.getAllVisibleColumns();
                this.lastVisibleColumn = allVisibleColumns[allVisibleColumns.length - 1];
            }
        }
        column.options.visible = visible;
        var w = this.contentWidthChange(newContentW);
        this.lastVisibleColumn.options.width = this.lastVisibleColumnWidth;
        this.contentWidth = w;
        this.resetThVariable();
        this.noScrollWidthReset();
        this.contentMinWidth = parseInt(this.wholeWidth) - parseInt(this.leftW) - parseInt(this.fixedWidth);
        if (this.contentMinWidth < 0) this.contentMinWidth = 0;
        if (this.contentRealWidth < this.contentMinWidth) {
            this.contentWidth = this.contentMinWidth;
            var oldWidth = this.lastVisibleColumn.options.width;
            this.lastVisibleColumnWidth = oldWidth + (this.contentMinWidth - this.contentRealWidth);
            // modfied by tianxq1 最后一列自动扩展
            this.lastVisibleColumn.options.width = this.lastVisibleColumnWidth;
            // this.setColumnWidth(this.lastVisibleColumn, this.lastVisibleColumnWidth);
        } else {
            this.contentWidth = this.contentRealWidth;
        }
        this.resetColumnWidthByRealWidth();
        this.saveGridCompColumnArrToLocal();

        var columnAllCheck = $('input', $('#' + this.options.id + '_column_menu_ul .header'));
        if (columnAllCheck.length > 0) {
            var lll = $('input:not(:checked)', $('#' + this.options.id + '_column_menu_columns_ul')).length;
            if (lll > 0) {
                columnAllCheck[0].checked = false;
            } else {
                columnAllCheck[0].checked = true;
            }
        }
    }
}
328399
private function applyColumnWidths()
	{
		$styles = [];
		if (!empty($this->columnWidth)) $styles['width'] = $this->prepareWidthStyleValue($this->columnWidth);
		if (!empty($this->minColumnWidth)) $styles['min-width'] = $this->prepareWidthStyleValue($this->minColumnWidth);
		if (!empty($this->maxColumnWidth)) $styles['max-width'] = $this->prepareWidthStyleValue($this->maxColumnWidth);

		Html::addCssStyle($this->options, $styles, true);
	}
735589
function() {
        var columnWidths = this.coordColumnModel.getWidths(this.whichSide);
        var columns = this.columnModel.getVisibleColumns(this.whichSide, true);

        return {
            widths: columnWidths,
            columns: columns
        };
    }
166812
def configure(self, cnf=None, **kw):
        
        if cnf == 'drag_cols':
            return 'drag_cols', self._drag_cols
        elif cnf == 'drag_rows':
            return 'drag_rows', self._drag_rows
        elif cnf == 'sortable':
            return 'sortable', self._sortable

        if isinstance(cnf, dict):
            kwargs = cnf.copy()
            kwargs.update(kw)  # keyword arguments override cnf content
            cnf = {}   # everything is in kwargs so no need of cnf
            cnf2 = {}  # to configure the preview
        else:
            kwargs = kw
            cnf2 = cnf

        sortable = bool(kwargs.pop("sortable", self._sortable))
        if sortable != self._sortable:
            self._config_sortable(sortable)
        drag_cols = bool(kwargs.pop("drag_cols", self._drag_cols))
        if drag_cols != self._drag_cols:
            self._config_drag_cols(drag_cols)
        self._drag_rows = bool(kwargs.pop("drag_rows", self._drag_rows))
        if 'columns' in kwargs:
            # update column type dict
            for col in list(self._column_types.keys()):
                if col not in kwargs['columns']:
                    del self._column_types[col]
            for col in kwargs['columns']:
                if col not in self._column_types:
                    self._column_types[col] = str
        # Remove some keywords from the preview configuration dict
        kw2 = kwargs.copy()
        kw2.pop('displaycolumns', None)
        kw2.pop('xscrollcommand', None)
        kw2.pop('yscrollcommand', None)
        self._visual_drag.configure(cnf2, **kw2)
        if len(kwargs) != 0:
            return ttk.Treeview.configure(self, cnf, **kwargs)
1088006
protected function initColumns()
	{
		if($this->columns===array())
		{
			if($this->dataProvider instanceof CActiveDataProvider)
				$this->columns=$this->dataProvider->model->attributeNames();
			elseif($this->dataProvider instanceof IDataProvider)
			{
				// use the keys of the first row of data as the default columns
				$data=$this->dataProvider->getData();
				if(isset($data[0]) && is_array($data[0]))
					$this->columns=array_keys($data[0]);
			}
		}
		$id=$this->getId();
		foreach($this->columns as $i=>$column)
		{
			if(is_string($column))
				$column=$this->createDataColumn($column);
			else
			{
				if(!isset($column['class']))
					$column['class']='CDataColumn';
				$column=Yii::createComponent($column, $this);
			}
			if(!$column->visible)
			{
				unset($this->columns[$i]);
				continue;
			}
			if($column->id===null)
				$column->id=$id.'_c'.$i;
			$this->columns[$i]=$column;
		}

		foreach($this->columns as $column)
			$column->init();
	}