PDA

View Full Version : GridPanel column menu problem with Selection Models



Foster
14 Jan 2011, 9:00 AM
Currently using ext 3.2 in my app, but also verified bug in 3.3.0 source (although the code was moved into a separate function)

Description of bug:

When using the header menu on a grid panel to check/uncheck columns, toggling the hidden property, the grid prevents you from turning off all columns at once ( at least one column *must* be displayed). This works appropriately.

However, if you have a checkboxSelectionModel on your grid, and use it as your first column so that you can check/uncheck to select rows, then the grid header menu allows you uncheck *all* columns, leaving your user with no columns in the grid. This is because the even though the header menu does not show the selectionmodel as a choice to turn on/off, it is still detected as a column, and the grid believes that at least one column is on.

The function


handleHdMenuClickDefault: function(item) {
invokes


if (item.checked && colModel.getColumnsBy(this.isHideableColumn, this).length <= 1) {
The fix is to change function isHideableColumn from


isHideableColumn : function(c) {
return !c.hidden;
},
[code]

to this:
[code]
isHideableColumn : function(c) {
return Ext.isDefined(c.singleSelect) ? false : !c.hidden;
},
I could not find any other way to determine if the column passed to the function is actually the selection model.

In my attached image, the top grid will not allow you to uncheck all columns, always making sure at least one column is visible.

The bottom grid allows you to uncheck all columns, making it so the user cannot use the grid unless they close the browser and reopen it

Condor
17 Jan 2011, 12:25 AM
Isn't this a duplicate of bug #1407 (http://www.sencha.com/forum/showthread.php?106541-OPEN-1407-GridPanel-w-CheckboxSelectionModel-can-hide-all-columns-(except-checkbox))?

Foster
17 Jan 2011, 5:36 AM
Thanks Condor! I see now that it is. I can try your previous solution and see what it looks like. Currently in my app I did the following and the users have accepted it as a resolution to their bug report.


Ext.override(Ext.Grid.GridView, {
isHideableColumn : function(c) {
return Ext.isDefined(c.singleSelect) ? false : !c.hidden;
}

});


This had the added benefit of allowing the user to turn off everything except the checkboxselectmodel and 1 column, however, I did not like having to check for the existence of singleSelect. If we ever move to version 4.0 I'm sure things will need to be reworked

Regards,
Foster