| Index: ui/webui/resources/js/cr/ui/table/table_column_model.js
|
| diff --git a/ui/webui/resources/js/cr/ui/table/table_column_model.js b/ui/webui/resources/js/cr/ui/table/table_column_model.js
|
| index da7803a0a13c810cfed967c7ad30cf2b9949afac..d159fd50a94dfd77935f2c9f24197a1064c63825 100644
|
| --- a/ui/webui/resources/js/cr/ui/table/table_column_model.js
|
| +++ b/ui/webui/resources/js/cr/ui/table/table_column_model.js
|
| @@ -97,12 +97,16 @@ cr.define('cr.ui.table', function() {
|
| if (index < 0 || index >= this.columns_.size - 1)
|
| return;
|
|
|
| + var column = this.columns_[index];
|
| width = Math.max(width, MIMIMAL_WIDTH);
|
| - if (width == this.columns_[index].width)
|
| + if (width == column.absoluteWidth)
|
| return;
|
|
|
| - this.columns_[index].width = width;
|
| - cr.dispatchSimpleEvent(this, 'resize');
|
| + column.width = width;
|
| +
|
| + // Dispatch an event if a visible column was resized.
|
| + if (column.visible)
|
| + cr.dispatchSimpleEvent(this, 'resize');
|
| },
|
|
|
| /**
|
| @@ -183,6 +187,35 @@ cr.define('cr.ui.table', function() {
|
| }
|
| return -1;
|
| },
|
| +
|
| + /**
|
| + * Show/hide a column.
|
| + * @param {number} index The column index.
|
| + * @param {boolean} visible The column visibility.
|
| + */
|
| + setVisible: function(index, visible) {
|
| + if (index < 0 || index > this.columns_.size - 1)
|
| + return;
|
| +
|
| + var column = this.columns_[index];
|
| + if (column.visible == visible)
|
| + return;
|
| +
|
| + // Changing column visibility alters the width. Save the total width out
|
| + // first, then change the column visibility, then relayout the table.
|
| + var contentWidth = this.totalWidth;
|
| + column.visible = visible;
|
| + this.normalizeWidths(contentWidth);
|
| + },
|
| +
|
| + /**
|
| + * Returns a column's visibility.
|
| + * @param {number} index The column index.
|
| + * @return {boolean} Whether the column is visible.
|
| + */
|
| + isVisible: function(index) {
|
| + return this.columns_[index].visible;
|
| + }
|
| };
|
|
|
| return {
|
|
|