Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: ui/webui/resources/js/cr/ui/table/table_list.js

Issue 1006003004: Adding a visibility property to cr.ui.table.TableColumn. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address feedback. Fix resize jank. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « ui/webui/resources/js/cr/ui/table/table_header.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/webui/resources/js/cr/ui/table/table_list.js
diff --git a/ui/webui/resources/js/cr/ui/table/table_list.js b/ui/webui/resources/js/cr/ui/table/table_list.js
index df39c0ec73d1e0047facbb051da3f174ec3b68cc..665dd017d8515c968ab274d1154c5ceb72dfd1fe 100644
--- a/ui/webui/resources/js/cr/ui/table/table_list.js
+++ b/ui/webui/resources/js/cr/ui/table/table_list.js
@@ -35,6 +35,10 @@ cr.define('cr.ui.table', function() {
* Resizes columns. Called when column width changed.
*/
resize: function() {
+ if (this.needsFullRedraw_()) {
+ this.redraw();
+ return;
+ }
if (this.updateScrollbars_())
List.prototype.redraw.call(this); // Redraw items only.
this.resizeCells_();
@@ -174,6 +178,7 @@ cr.define('cr.ui.table', function() {
cell.className = 'table-row-cell';
if (cm.isEndAlign(i))
cell.style.textAlign = 'end';
+ cell.hidden = !cm.isVisible(i);
cell.appendChild(
cm.getRenderFunction(i).call(null, dataItem, cm.getId(i), table));
@@ -183,6 +188,25 @@ cr.define('cr.ui.table', function() {
return listItem;
},
+
+ /**
+ * Determines whether a full redraw is required.
+ * @return {boolean}
+ */
+ needsFullRedraw_: function() {
+ var cm = this.table_.columnModel;
+ var row = this.firstElementChild;
+ // If the number of columns in the model has changed, a full redraw is
+ // needed.
+ if (row.children.length != cm.size)
+ return true;
+ // If the column visibility has changed, a full redraw is required.
+ for (var i = 0; i < cm.size; ++i) {
+ if (cm.isVisible(i) == row.children[i].hidden)
+ return true;
+ }
+ return false;
+ },
};
/**
« no previous file with comments | « ui/webui/resources/js/cr/ui/table/table_header.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698