Fix action column removal to handle action columns that are not the last column

This commit is contained in:
Nathan Gray 2012-05-29 17:22:18 +00:00
parent f8fbafd086
commit 2b3686540f

View File

@ -480,6 +480,10 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
// Go over the header row and create the column entries // Go over the header row and create the column entries
this.columns = new Array(_row.length); this.columns = new Array(_row.length);
var columnData = new Array(_row.length); var columnData = new Array(_row.length);
// No action columns in et2
var remove_action_index = null;
for (var x = 0; x < _row.length; x++) for (var x = 0; x < _row.length; x++)
{ {
this.columns[x] = { this.columns[x] = {
@ -490,18 +494,16 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
columnData[x] = { columnData[x] = {
"id": "col_" + x, "id": "col_" + x,
"caption": this._genColumnCaption(_row[x].widget), "caption": this._genColumnCaption(_row[x].widget),
"visibility": _colData[x].disabled ? "visibility": (!_colData[x] || _colData[x].disabled) ?
ET2_COL_VISIBILITY_INVISIBLE : ET2_COL_VISIBILITY_VISIBLE, ET2_COL_VISIBILITY_INVISIBLE : ET2_COL_VISIBILITY_VISIBLE,
"width": _colData[x].width "width": _colData[x] ? _colData[x].width : 0
}; };
// No action columns in et2 // No action columns in et2
var colName = this._getColumnName(_row[x].widget); var colName = this._getColumnName(_row[x].widget);
if(colName == 'actions' || colName == 'legacy_actions' || colName == 'legacy_actions_check_all') if(colName == 'actions' || colName == 'legacy_actions' || colName == 'legacy_actions_check_all')
{ {
this.columns.splice(x,x); remove_action_index = x;
columnData.splice(x,x);
_colData.splice(x,x);
continue; continue;
} }
@ -509,6 +511,14 @@ var et2_nextmatch = et2_DOMWidget.extend([et2_IResizeable, et2_IInput], {
this.addChild(_row[x].widget); this.addChild(_row[x].widget);
} }
// Remove action column
if(remove_action_index != null)
{
this.columns.splice(x,x);
columnData.splice(x,x);
_colData.splice(x,x);
}
// Create the column manager and update the grid container // Create the column manager and update the grid container
this.dataview.setColumns(columnData); this.dataview.setColumns(columnData);