我为每个表都有一个 ActionColumn。我需要order => ORDER_FIX_RIGHT
为 ActionColumn 添加每个表。如何order
在我的 DynaGridViewAdvanced 中添加密钥?
我试着写:
protected function applyColumns()
{
$columns = [];
$newColumns = [];
foreach ($this->columns as $column) {
$order = ArrayHelper::getValue($column, 'order', self::ORDER_MIDDLE);
if ($order == self::ORDER_FIX_LEFT) {
$newColumns[] = $column;
unset($column['order']);
$columns[] = $column;
}
}
foreach ($this->_visibleKeys as $key) {
if (empty($this->_columns[$key])) {
continue;
}
$column = $this->_columns[$key];
$newColumns[] = $column;
if (isset($column['order'])) {
unset($column['order']);
}
if (isset($column['visible'])) {
unset($column['visible']);
}
$columns[] = $column;
}
foreach ($this->columns as $column) {
$order = ArrayHelper::getValue($column, 'order', self::ORDER_MIDDLE);
$isActionColumn = is_array($column) && array_key_exists('class', $column) && (new $column['class']) instanceof ActionColumn;
if ($order == self::ORDER_FIX_RIGHT) {
$newColumns[] = $column;
unset($column['order']);
$columns[] = $column;
}
if ($isActionColumn) {
$column['order'] = self::ORDER_FIX_RIGHT;
$newColumns[] = $column;
unset($column['order']);
$columns[] = $column;
}
}
$this->columns = $newColumns;
$this->gridOptions['columns'] = $columns;
}
但它是第二列。如果我写:
protected function prepareColumns()
{
$this->_columns = $this->columns;
$columns = [];
foreach ($this->columns as $column) {
$isActionColumn = is_array($column) && array_key_exists('class', $column) && (new $column['class']) instanceof ActionColumn;
if (is_array($column) && !$isActionColumn) {
unset($column['order']);
}
if ($isActionColumn) {
$column['order'] = $this->actionColumnsPosition;
}
$columns[] = $column;
}
$this->gridOptions['columns'] = $columns;
}
一切正常,但是当我在列中更改一些内容时,我有以下例外:
设置未知属性 ...ActionColumn::order