Index: col_picker_helper.php =================================================================== --- col_picker_helper.php (revision 12948) +++ col_picker_helper.php (working copy) @@ -77,21 +77,40 @@ function RebuildColumns($prefix, $current=null) { + // get default columns from unit config $cols = $this->GetColumns($prefix); if (is_array($current)) { - //get common fields both in db and xml + // 1. prepare visible columns + + // keep user column order (common columns between user and default grid) $common = array_intersect($current['order'], $cols['order']); - //get added columns - present in xml, but not in db + // get new columns (found in default grid, but not found in user's grid) $added = array_diff($cols['order'], $current['order']); + if (in_array('__FREEZER__', $added)) { + // in case if freezer was added, then make it first column array_unshift($common, '__FREEZER__'); unset($added[array_search('__FREEZER__', $added)]); } $cols['order'] = array_merge($common, $added); - $cols['hidden_fields'] = array_intersect($current['order'], $current['hidden_fields']); + + // 2. prepare hidden columns + if ($added) { + $hidden_added = array_intersect($added, $cols['hidden_fields']); + $cols['hidden_fields'] = array_intersect($current['order'], $current['hidden_fields']); + + // when some of new columns are hidden, then keep them hidden + foreach ($hidden_added as $position => $field) { + $cols['hidden_fields'][$position] = $field; + } + } + else { + $cols['hidden_fields'] = array_intersect($current['order'], $current['hidden_fields']); + } + foreach($common as $col) { $cols['widths'][$col] = isset($current['widths'][$col]) ? $current['widths'][$col] : 100; }