Fixed data table view bugs: collapsed columns should now stay collapsed even if the column model changes.

git-svn-id: http://google-refine.googlecode.com/svn/trunk@266 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
David Huynh 2010-03-10 07:12:09 +00:00
parent e008332399
commit 0160b6841d
2 changed files with 18 additions and 6 deletions

View File

@ -288,18 +288,29 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
{
label: "Collapse This Column",
click: function() {
theProject.columnModel.columns[self._columnIndex].collapsed = true;
self._dataTableView._collapsedColumnNames[self._column.name] = true;
self._dataTableView.render();
}
},
{
label: "Collapse All Other Columns",
click: function() {
var collapsedColumnNames = {}
for (var i = 0; i < theProject.columnModel.columns.length; i++) {
if (i != self._columnIndex) {
theProject.columnModel.columns[i].collapsed = true;
collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
}
self._dataTableView._collapsedColumnNames = collapsedColumnNames;
self._dataTableView.render();
}
},
{
label: "Collapse All Columns To Left",
click: function() {
for (var i = 0; i < self._columnIndex; i++) {
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}
},
@ -307,7 +318,7 @@ DataTableColumnHeaderUI.prototype._createMenuForColumnHeader = function(elmt) {
label: "Collapse All Columns To Right",
click: function() {
for (var i = self._columnIndex + 1; i < theProject.columnModel.columns.length; i++) {
theProject.columnModel.columns[i].collapsed = true;
self._dataTableView._collapsedColumnNames[theProject.columnModel.columns[i].name] = true;
}
self._dataTableView.render();
}

View File

@ -2,6 +2,7 @@ function DataTableView(div) {
this._div = div;
this._pageSize = 20;
this._showRecon = true;
this._collapsedColumnNames = {};
this._initializeUI();
this._showRows(0);
@ -190,9 +191,9 @@ DataTableView.prototype.render = function() {
var td = trHead.insertCell(trHead.cells.length);
$(td).addClass("column-header");
if (column.collapsed) {
if (column.name in self._collapsedColumnNames) {
$(td).html("&nbsp;").attr("title", column.name).click(function(evt) {
column.collapsed = false;
delete self._collapsedColumnNames[column.name]
self.render();
});
} else {
@ -253,7 +254,7 @@ DataTableView.prototype.render = function() {
for (var i = 0; i < columns.length; i++) {
var column = columns[i];
var td = tr.insertCell(tr.cells.length);
if (column.collapsed) {
if (column.name in self._collapsedColumnNames) {
td.innerHTML = "&nbsp;";
} else {
var cell = (column.cellIndex < cells.length) ? cells[column.cellIndex] : null;