PDA

View Full Version : [FIXED-1478] GridFilters error icw LockingGridView



Condor
4 Jan 2011, 4:44 AM
GridFilters will throw an error when locking a column from the header menu of a LockingGridView (except the first unlocked column).

Patch:

Ext.override(Ext.ux.grid.LockingGridView, {
handleHdMenuClick : function(item){
var index = this.hdCtxIndex,
cm = this.cm,
id = item.getItemId(),
llen = cm.getLockedCount();
switch(id){
case 'lock':
if(cm.getColumnCount(true) <= llen + 1){
this.onDenyColumnLock();
return undefined;
}
cm.setLocked(index, true, llen != index);
if(llen != index){
cm.moveColumn(index, llen);
this.grid.fireEvent('columnmove', index, llen);
}
break;
case 'unlock':
if(llen - 1 != index){
cm.setLocked(index, false, true);
cm.moveColumn(index, llen - 1);
this.grid.fireEvent('columnmove', index, llen - 1);
}else{
cm.setLocked(index, false);
}
break;
default:
return Ext.ux.grid.LockingGridView.superclass.handleHdMenuClick.call(this, item);
}
return true;
}
});

Or with less code:

Ext.override(Ext.ux.grid.LockingGridView, {
handleHdMenuClick: function (item) {
var index = this.hdCtxIndex,
cm = this.cm,
id = item.getItemId(),
llen = cm.getLockedCount(),
lock = false,
move;
switch (id) {
case 'lock':
llen++;
if (cm.getColumnCount(true) <= llen) {
this.onDenyColumnLock();
return undefined;
}
lock = true;
case 'unlock':
llen--;
move = llen != index;
cm.setLocked(index, lock, move);
if (move) {
cm.moveColumn(index, llen);
this.grid.fireEvent('columnmove', index, llen);
}
break;
default:
return Ext.ux.grid.LockingGridView.superclass.handleHdMenuClick.call(this, item);
}
return true;
}
});
But this makes JSLint complain:
Problem at line 16 character 24: Expected a 'break' statement before 'case'.

meroy
4 Jan 2011, 11:08 AM
Thanks for the report. This has been fixed in SVN (3.3.x branch).